-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Related to #340
- Loading branch information
Showing
53 changed files
with
1,523 additions
and
125 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
packages/form-js-editor/src/features/properties-panel/entries/DateTimeConstraintsEntry.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import { CheckboxEntry, isCheckboxEntryEdited, SelectEntry, isSelectEntryEdited } from '@bpmn-io/properties-panel'; | ||
|
||
import { DATETIME_SUBTYPES, DATETIME_DISALLOWPASTDATES_PATH, TIME_INTERVAL_PATH } from '@bpmn-io/form-js-viewer'; | ||
|
||
import { get } from 'min-dash'; | ||
|
||
export default function DateTimeConstraintsEntry(props) { | ||
const { | ||
editField, | ||
field, | ||
id | ||
} = props; | ||
|
||
const { | ||
type, | ||
subtype | ||
} = field; | ||
|
||
if (type !== 'datetime') { | ||
return []; | ||
} | ||
|
||
const entries = []; | ||
|
||
if (subtype === DATETIME_SUBTYPES.TIME || subtype === DATETIME_SUBTYPES.DATETIME) { | ||
entries.push({ | ||
id: id + '-timeInterval', | ||
component: TimeIntervalSelect, | ||
isEdited: isSelectEntryEdited, | ||
editField, | ||
field | ||
}); | ||
} | ||
|
||
if (subtype === DATETIME_SUBTYPES.DATE || subtype === DATETIME_SUBTYPES.DATETIME) { | ||
entries.push({ | ||
id: id + '-disallowPassedDates', | ||
component: DisallowPassedDates, | ||
isEdited: isCheckboxEntryEdited, | ||
editField, | ||
field | ||
}); | ||
} | ||
|
||
return entries; | ||
} | ||
|
||
function DisallowPassedDates(props) { | ||
const { | ||
editField, | ||
field, | ||
id | ||
} = props; | ||
|
||
const path = DATETIME_DISALLOWPASTDATES_PATH; | ||
|
||
const getValue = () => { | ||
return get(field, path, ''); | ||
}; | ||
|
||
const setValue = (value) => { | ||
return editField(field, path, value); | ||
}; | ||
|
||
return CheckboxEntry({ | ||
element: field, | ||
getValue, | ||
id, | ||
label: 'Disallow past dates', | ||
setValue | ||
}); | ||
} | ||
|
||
function TimeIntervalSelect(props) { | ||
|
||
const { | ||
editField, | ||
field, | ||
id | ||
} = props; | ||
|
||
const timeIntervals = [ 1, 5, 10, 15, 30, 60 ]; | ||
|
||
const getValue = (e) => get(field, TIME_INTERVAL_PATH); | ||
|
||
const setValue = (value) => editField(field, TIME_INTERVAL_PATH, parseInt(value)); | ||
|
||
const getTimeIntervals = () => { | ||
|
||
return timeIntervals.map((timeInterval) => ({ | ||
label: timeInterval === 60 ? '1h' : (timeInterval + 'm'), | ||
value: timeInterval | ||
})); | ||
}; | ||
|
||
return SelectEntry({ | ||
label: 'Time interval', | ||
element: field, | ||
getOptions: getTimeIntervals, | ||
getValue, | ||
id, | ||
setValue | ||
}); | ||
} |
64 changes: 64 additions & 0 deletions
64
packages/form-js-editor/src/features/properties-panel/entries/DateTimeDisplayEntry.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { CheckboxEntry, isCheckboxEntryEdited } from '@bpmn-io/properties-panel'; | ||
|
||
import { DATETIME_SUBTYPES, TIME_USE24H_PATH } from '@bpmn-io/form-js-viewer'; | ||
|
||
import { get } from 'min-dash'; | ||
|
||
export default function DateTimeDisplayEntry(props) { | ||
const { | ||
editField, | ||
field, | ||
id | ||
} = props; | ||
|
||
const { | ||
type, | ||
subtype | ||
} = field; | ||
|
||
if (type !== 'datetime') { | ||
return []; | ||
} | ||
|
||
const entries = []; | ||
|
||
if (subtype === DATETIME_SUBTYPES.TIME || subtype === DATETIME_SUBTYPES.DATETIME) { | ||
|
||
entries.push({ | ||
id: id + '-use24h', | ||
component: Use24h, | ||
isEdited: isCheckboxEntryEdited, | ||
editField, | ||
field | ||
}); | ||
|
||
} | ||
|
||
return entries; | ||
} | ||
|
||
function Use24h(props) { | ||
const { | ||
editField, | ||
field, | ||
id | ||
} = props; | ||
|
||
const path = TIME_USE24H_PATH; | ||
|
||
const getValue = () => { | ||
return get(field, path, ''); | ||
}; | ||
|
||
const setValue = (value) => { | ||
return editField(field, path, value); | ||
}; | ||
|
||
return CheckboxEntry({ | ||
element: field, | ||
getValue, | ||
id, | ||
label: 'Use 24h', | ||
setValue | ||
}); | ||
} |
64 changes: 64 additions & 0 deletions
64
packages/form-js-editor/src/features/properties-panel/entries/DateTimeEntry.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { SelectEntry, isSelectEntryEdited } from '@bpmn-io/properties-panel'; | ||
|
||
import { DATETIME_SUBTYPES, DATETIME_SUBTYPES_LABELS, DATETIME_SUBTYPE_PATH } from '@bpmn-io/form-js-viewer'; | ||
|
||
import { get } from 'min-dash'; | ||
|
||
export default function DateTimeEntry(props) { | ||
const { | ||
editField, | ||
field, | ||
id | ||
} = props; | ||
|
||
const { | ||
type | ||
} = field; | ||
|
||
if (type !== 'datetime') { | ||
return []; | ||
} | ||
|
||
const entries = [ | ||
{ | ||
id: id + '-subtype-select', | ||
component: DateTimeSubtypeSelect, | ||
isEdited: isSelectEntryEdited, | ||
editField, | ||
field | ||
} | ||
]; | ||
|
||
return entries; | ||
} | ||
|
||
function DateTimeSubtypeSelect(props) { | ||
|
||
const { | ||
editField, | ||
field, | ||
id | ||
} = props; | ||
|
||
const getValue = (e) => get(field, DATETIME_SUBTYPE_PATH); | ||
|
||
const setValue = (value) => editField(field, DATETIME_SUBTYPE_PATH, value); | ||
|
||
const getDatetimeSubtypes = () => { | ||
|
||
return Object.values(DATETIME_SUBTYPES).map((subtype) => ({ | ||
label: DATETIME_SUBTYPES_LABELS[subtype], | ||
value: subtype | ||
})); | ||
}; | ||
|
||
return SelectEntry({ | ||
label: 'Subtype', | ||
element: field, | ||
getOptions: getDatetimeSubtypes, | ||
getValue, | ||
id, | ||
setValue | ||
}); | ||
} | ||
|
Oops, something went wrong.