Skip to content

Commit

Permalink
Add revert changes button
Browse files Browse the repository at this point in the history
  • Loading branch information
Morozov Saveliy committed Apr 5, 2023
1 parent 81e0de4 commit ae0b517
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
34 changes: 34 additions & 0 deletions addon/components/fd-sheets/fd-diagram-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ export default FdBaseSheet.extend(
iconClasses: ' icon-fd-uml-edit icon',
buttonAction: this.get('umlСorrector').bind(this)
},
{
buttonTitle: i18n.t('components.fd-diagram-editing-panel.revert-changes-title'),
buttonVisible: !this.get('readonlyMode'),
iconClasses: 'reply all icon',
buttonAction: this.get('revertChanges').bind(this)
},
{
buttonTitle: i18n.t('components.fd-diagram-editing-panel.toggler-caption'),
buttonVisible: this.get('selectedValue.data.isNew') || (!this.get('isAddMode') && !this.get('readonlyMode')),
Expand Down Expand Up @@ -673,6 +679,34 @@ export default FdBaseSheet.extend(
this.get('systemObserver').apply(this);
},

revertChanges() {
const store = this.get('store');
const stageId = this.get('currentProjectContext').getCurrentStageModel().get('id');
const revert = () => {
this.openSheet(this.get('sheetComponentName'), this.get('selectedValue'));
}
const currentStageRecords = new A([
store.peekAll('fd-dev-class').filterBy('stage.id', stageId),
store.peekAll('fd-dev-view').filterBy('stage.id', stageId),
store.peekAll('fd-dev-form-view').filterBy('stage.id', stageId),
store.peekAll('fd-dev-attribute').filterBy('stage.id', stageId),
store.peekAll('fd-dev-inheritance').filterBy('stage.id', stageId),
store.peekAll('fd-dev-aggregation').filterBy('stage.id', stageId),
]).flat();

const dirtyRecords = currentStageRecords.filter(hasChanges);

if (dirtyRecords.length === 0) {
return;
}

this.get('fdDialogService').showVerificationMessage(
this.get('i18n').t('components.fd-modal-message-box.confirmation-text').toString(),
revert,
this
);
},

/**
Flag indicates when toolbar is collapsed.
Expand Down
3 changes: 2 additions & 1 deletion addon/locales/en/components/fd-diagram-editing-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export default {
'open-edit-form-title': 'Open edit form',
'collapse-title': 'Collapse object',
'uml-validator-title': 'UML validator',
'uml-corrector-title': 'UML corrector'
'uml-corrector-title': 'UML corrector',
'revert-changes-title': 'Revert changes'
};
3 changes: 2 additions & 1 deletion addon/locales/ru/components/fd-diagram-editing-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export default {
'open-edit-form-title': 'Открыть форму редактирования свойств',
'collapse-title': 'Свернуть объект',
'uml-validator-title': 'UML валидатор',
'uml-corrector-title': 'UML корректор'
'uml-corrector-title': 'UML корректор',
'revert-changes-title': 'Отмена всех изменений'
};

0 comments on commit ae0b517

Please sign in to comment.