diff --git a/demo-shell-ng2/package.json b/demo-shell-ng2/package.json index 22a2b7caaf..b93a1936d9 100644 --- a/demo-shell-ng2/package.json +++ b/demo-shell-ng2/package.json @@ -71,7 +71,7 @@ "zone.js": "0.6.12", "rimraf": "2.5.2", "material-design-icons": "2.2.3", - "material-design-lite": "1.1.3", + "material-design-lite": "1.2.1", "ng2-translate": "2.2.0", "pdfjs-dist": "1.5.404", "flag-icon-css": "2.3.0", diff --git a/ng2-components/ng2-activiti-form/src/components/activiti-form.component.html b/ng2-components/ng2-activiti-form/src/components/activiti-form.component.html index 0379e071e0..36521d3c6b 100644 --- a/ng2-components/ng2-activiti-form/src/components/activiti-form.component.html +++ b/ng2-components/ng2-activiti-form/src/components/activiti-form.component.html @@ -4,8 +4,9 @@
-
-

{{form.taskName}}

+
+ {{ form.isValid ? 'event_available' : 'event_busy' }} +

{{form.taskName}}

@@ -19,9 +20,9 @@
diff --git a/ng2-components/ng2-activiti-form/src/components/activiti-form.component.spec.ts b/ng2-components/ng2-activiti-form/src/components/activiti-form.component.spec.ts index 37204d11d6..4a639e9c5e 100644 --- a/ng2-components/ng2-activiti-form/src/components/activiti-form.component.spec.ts +++ b/ng2-components/ng2-activiti-form/src/components/activiti-form.component.spec.ts @@ -22,7 +22,7 @@ import { ActivitiForm } from './activiti-form.component'; import { FormModel, FormOutcomeModel, FormFieldModel, FormOutcomeEvent } from './widgets/index'; import { FormService } from './../services/form.service'; import { WidgetVisibilityService } from './../services/widget-visibility.service'; -import { ContainerWidget } from './widgets/container/container.widget'; +// import { ContainerWidget } from './widgets/container/container.widget'; describe('ActivitiForm', () => { @@ -98,13 +98,13 @@ describe('ActivitiForm', () => { }); it('should not enable outcome button when model missing', () => { - expect(formComponent.isOutcomeButtonEnabled(null)).toBeFalsy(); + expect(formComponent.isOutcomeButtonVisible(null)).toBeFalsy(); }); it('should enable custom outcome buttons', () => { let formModel = new FormModel(); let outcome = new FormOutcomeModel(formModel, { id: 'action1', name: 'Action 1' }); - expect(formComponent.isOutcomeButtonEnabled(outcome)).toBeTruthy(); + expect(formComponent.isOutcomeButtonVisible(outcome)).toBeTruthy(); }); @@ -113,10 +113,10 @@ describe('ActivitiForm', () => { let outcome = new FormOutcomeModel(formModel, { id: '$save', name: FormOutcomeModel.SAVE_ACTION }); formComponent.showSaveButton = true; - expect(formComponent.isOutcomeButtonEnabled(outcome)).toBeTruthy(); + expect(formComponent.isOutcomeButtonVisible(outcome)).toBeTruthy(); formComponent.showSaveButton = false; - expect(formComponent.isOutcomeButtonEnabled(outcome)).toBeFalsy(); + expect(formComponent.isOutcomeButtonVisible(outcome)).toBeFalsy(); }); it('should allow controlling [save] button visibility', () => { @@ -124,10 +124,10 @@ describe('ActivitiForm', () => { let outcome = new FormOutcomeModel(formModel, { id: '$save', name: FormOutcomeModel.COMPLETE_ACTION }); formComponent.showCompleteButton = true; - expect(formComponent.isOutcomeButtonEnabled(outcome)).toBeTruthy(); + expect(formComponent.isOutcomeButtonVisible(outcome)).toBeTruthy(); formComponent.showCompleteButton = false; - expect(formComponent.isOutcomeButtonEnabled(outcome)).toBeFalsy(); + expect(formComponent.isOutcomeButtonVisible(outcome)).toBeFalsy(); }); it('should load form on refresh', () => { @@ -571,6 +571,7 @@ describe('ActivitiForm', () => { expect(formComponent.getFormDefinitionOutcomes).toHaveBeenCalledWith(form); }); + /* it('should update the visibility when the container raise the change event', (valueChanged) => { spyOn(formComponent, 'checkVisibility').and.callThrough(); let widget = new ContainerWidget(); @@ -581,6 +582,7 @@ describe('ActivitiForm', () => { expect(formComponent.checkVisibility).toHaveBeenCalledWith(fakeField); }); + */ it('should prevent default outcome execution', () => { diff --git a/ng2-components/ng2-activiti-form/src/components/activiti-form.component.ts b/ng2-components/ng2-activiti-form/src/components/activiti-form.component.ts index d8d4c61755..721bd0a45b 100644 --- a/ng2-components/ng2-activiti-form/src/components/activiti-form.component.ts +++ b/ng2-components/ng2-activiti-form/src/components/activiti-form.component.ts @@ -128,7 +128,7 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges { showSaveButton: boolean = true; @Input() - showDebugButton: boolean = false; + showDebugButton: boolean = true; @Input() readOnly: boolean = false; @@ -175,6 +175,21 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges { } isOutcomeButtonEnabled(outcome: FormOutcomeModel): boolean { + if (this.form.readOnly) { + return false; + } + + if (outcome) { + // Make 'Save' button always available + if (outcome.name === FormOutcomeModel.SAVE_ACTION) { + return true; + } + return this.form.isValid; + } + return false; + } + + isOutcomeButtonVisible(outcome: FormOutcomeModel): boolean { if (outcome && outcome.name) { if (outcome.name === FormOutcomeModel.COMPLETE_ACTION) { return this.showCompleteButton; diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/checkbox/checkbox.widget.html b/ng2-components/ng2-activiti-form/src/components/widgets/checkbox/checkbox.widget.html index 67862db94d..1e7ba71ff5 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/checkbox/checkbox.widget.html +++ b/ng2-components/ng2-activiti-form/src/components/widgets/checkbox/checkbox.widget.html @@ -1,6 +1,7 @@