Skip to content

Commit

Permalink
Planning date field
Browse files Browse the repository at this point in the history
  • Loading branch information
thecalcc committed Dec 3, 2024
1 parent 8ffb3a7 commit f691141
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1,823 deletions.
33 changes: 29 additions & 4 deletions client/components/planning-editor-standalone/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import {OrderedMap} from 'immutable';
import {
IAuthoringFieldV2,
IContentProfileV2,
IDateFieldConfig,
IDropdownConfigManualSource,
IDropdownConfigVocabulary,
IDateTimeFieldConfig,
IEditor3Config,
} from 'superdesk-api';
import {planningApi, superdeskApi} from '../../superdeskApi';
Expand Down Expand Up @@ -36,6 +34,24 @@ function getTextFieldConfig(options: {id: string; label: string, required: boole
return field;
}

function getDateTimeField(options: {id: string; label: string, required: boolean}): IAuthoringFieldV2 {
const config: IDateTimeFieldConfig = {
allowSeconds: false,
};

const field: IAuthoringFieldV2 = {
id: options.id,
name: options.label,
fieldType: 'datetime',
fieldConfig: {
...config,
required: options.required,
},
};

return field;
}

export function getProfile() {
const planningProfile = planningApi.contentProfiles.get('planning');
const planningGroups = getEditorFormGroupsFromProfile(planningProfile);
Expand Down Expand Up @@ -100,6 +116,15 @@ export function getProfile() {
fieldId,
field,
);
} else if (fieldId === 'planning_date') {
profileV2.header = profileV2.header.set(
fieldId,
getDateTimeField({
id: fieldId,
label: gettext('Planning date'),
required: required,
}),
);
}

// else if (fieldId === 'language') {
Expand Down Expand Up @@ -215,4 +240,4 @@ export function getProfile() {
console.log('skipped -------------------------------- ', skipped, superdeskApi.entities.vocabulary.getAll());

return profileV2;
}
}
Loading

0 comments on commit f691141

Please sign in to comment.