Skip to content

Automated cherry pick of #1336: fix(dop): add default value for custom fields when quick create issue #1351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -627,12 +627,12 @@ export const EditIssueDrawer = (props: IProps) => {
const defaultCustomFormData = React.useMemo(() => {
const customFieldDefaultValues = {};
map(fieldList, (item) => {
if (item?.required) {
if (item?.propertyType === 'Select') {
customFieldDefaultValues[item?.propertyName] = item?.enumeratedValues[0]?.id;
if (item && item.required) {
if (item.propertyType === 'Select') {
customFieldDefaultValues[item.propertyName] = item.enumeratedValues?.[0].id;
}
if (item?.propertyType === 'MultiSelect') {
customFieldDefaultValues[item?.propertyName] = [item?.enumeratedValues[0]?.id];
if (item.propertyType === 'MultiSelect') {
customFieldDefaultValues[item.propertyName] = [item.enumeratedValues?.[0].id];
}
}
});
Expand Down Expand Up @@ -712,23 +712,23 @@ export const EditIssueDrawer = (props: IProps) => {
}, [propsIssueType]);

React.useEffect(() => {
if (id && visible) {
getIssueDetail({ type: issueType, id });
getIssueStreams({ type: issueType, id, pageNo: 1, pageSize: 50 });
getCustomFields();
} else {
visible &&
getCustomFieldsByProject({
propertyIssueType: issueType,
if (visible) {
if (id) {
getIssueDetail({ type: issueType, id });
getIssueStreams({ type: issueType, id, pageNo: 1, pageSize: 50 });
getCustomFields();
}
getCustomFieldsByProject({
propertyIssueType: issueType,
orgID,
}).then((res) => {
updateCustomFieldDetail({
property: res,
orgID,
}).then((res) => {
updateCustomFieldDetail({
property: res,
orgID,
projectID: +addRelatedMattersProjectId,
issueID: undefined,
});
projectID: +addRelatedMattersProjectId,
issueID: undefined,
});
});
}
}, [
addRelatedMattersProjectId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ const AddNewIssue = ({ onSaveRelation, iterationID, onCancel, defaultIssueType }
...val,
}).then((res: number) => {
onSaveRelation(res); // 添加关联
return res;
});
}}
/>
Expand Down
24 changes: 23 additions & 1 deletion shell/app/modules/project/pages/backlog/issue-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import routeInfoStore from 'core/stores/route';
import userStore from 'app/user/stores';
import { useUserMap } from 'core/stores/userMap';
import { useMount } from 'react-use';
import issueStore from 'project/stores/issues';
import issueFieldStore from 'org/stores/issue-field';
import orgStore from 'app/org-home/stores/org';

export enum BACKLOG_ISSUE_TYPE {
iterationIssue = 'iterationIssue',
Expand Down Expand Up @@ -157,6 +160,13 @@ export const IssueForm = (props: IIssueFormProps) => {
const formRef = React.useRef(null as any);
const { projectId } = routeInfoStore.getState((s) => s.params);
const [shouldAutoFocus, setShouldAutoFocus] = React.useState(true);
const { addFieldsToIssue } = issueStore.effects;
const [bugStageList, taskTypeList, fieldList] = issueFieldStore.useStore((s) => [
s.bugStageList,
s.taskTypeList,
s.fieldList,
]);
const orgID = orgStore.useStore((s) => s.currentOrg.id);

useMount(() => {
setShouldAutoFocus(false);
Expand All @@ -167,7 +177,19 @@ export const IssueForm = (props: IIssueFormProps) => {
if (curForm) {
curForm.onSubmit((val: ISSUE.BacklogIssueCreateBody) => {
if (val.title) {
onOk(val).then(() => curForm.reset('title'));
const data = {
...val,
// some special fields for different type
taskType: taskTypeList?.length ? taskTypeList[0].value : '',
bugStage: bugStageList?.length ? bugStageList[0].value : '',
owner: '',
};
onOk(data).then((res) => {
curForm.reset('title');
if (fieldList.length) {
addFieldsToIssue({ property: fieldList, issueID: res, orgID, projectID: +projectId });
}
});
} else {
message.warn(i18n.t('please enter {name}', { name: i18n.t('title') }));
}
Expand Down