How to use the @alfresco/adf-core.FormOutcomeModel function in @alfresco/adf-core

To help you get started, we’ve selected a few @alfresco/adf-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Alfresco / alfresco-ng2-components / lib / process-services / src / lib / form / form.component.spec.ts View on Github external
it('should show [custom-outcome] button with readOnly form and selected custom-outcome', () => {
        const formModel = new FormModel({ selectedOutcome: 'custom-outcome' });
        formModel.readOnly = true;
        formComponent.form = formModel;
        let outcome = new FormOutcomeModel(formModel, { id: '$customoutome', name: 'custom-outcome' });

        formComponent.showCompleteButton = true;
        formComponent.showSaveButton = true;
        expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeTruthy();

        outcome = new FormOutcomeModel(formModel, { id: '$customoutome2', name: 'custom-outcome2' });
        expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeFalsy();
    });
github Alfresco / alfresco-ng2-components / lib / process-services / src / lib / form / form.component.spec.ts View on Github external
it('should complete form on [complete] outcome click', () => {
        const formModel = new FormModel();
        const outcome = new FormOutcomeModel(formModel, {
            id: FormComponent.COMPLETE_OUTCOME_ID,
            name: 'Complete',
            isSystem: true
        });

        formComponent.form = formModel;
        spyOn(formComponent, 'completeTaskForm').and.stub();

        const result = formComponent.onOutcomeClicked(outcome);
        expect(result).toBeTruthy();
        expect(formComponent.completeTaskForm).toHaveBeenCalled();
    });
github Alfresco / alfresco-ng2-components / lib / process-services / src / lib / form / form.component.spec.ts View on Github external
it('should show only [complete] button with readOnly form ', () => {
        const formModel = new FormModel();
        formModel.readOnly = true;
        formComponent.form = formModel;
        const outcome = new FormOutcomeModel(formModel, { id: '$complete', name: FormOutcomeModel.COMPLETE_ACTION });

        formComponent.showCompleteButton = true;
        expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeTruthy();
    });
github Alfresco / alfresco-ng2-components / lib / process-services / src / lib / form / form.component.spec.ts View on Github external
it('should prevent default outcome execution', () => {

        const outcome = new FormOutcomeModel(new FormModel(), {
            id: FormComponent.CUSTOM_OUTCOME_ID,
            name: 'Custom'
        });

        formComponent.form = new FormModel();
        formComponent.executeOutcome.subscribe((event: FormOutcomeEvent) => {
            expect(event.outcome).toBe(outcome);
            event.preventDefault();
            expect(event.defaultPrevented).toBeTruthy();
        });

        const result = formComponent.onOutcomeClicked(outcome);
        expect(result).toBeFalsy();
    });
github Alfresco / alfresco-ng2-components / lib / process-services / src / lib / form / form.component.spec.ts View on Github external
it('should raise [executeOutcome] event for formService', (done) => {
        formService.executeOutcome.subscribe(() => {
            done();
        });

        const outcome = new FormOutcomeModel(new FormModel(), {
            id: FormComponent.CUSTOM_OUTCOME_ID,
            name: 'Custom'
        });

        formComponent.form = new FormModel();
        formComponent.onOutcomeClicked(outcome);
    });
github Alfresco / alfresco-ng2-components / lib / process-services / src / lib / form / form.component.spec.ts View on Github external
const formModel = new FormModel();

        const field = new FormFieldModel(formModel, {
            type: 'text',
            value: 'text',
            required: true
        });

        const containerModel = new ContainerModel(field);
        formModel.fields.push(containerModel);
        formComponent.form = formModel;
        formModel.onFormFieldChanged(field);

        expect(formModel.isValid).toBeTruthy();

        const saveOutcome = new FormOutcomeModel(new FormModel(), {
            id: FormComponent.SAVE_OUTCOME_ID,
            name: FormOutcomeModel.SAVE_ACTION
        });

        formComponent.form.readOnly = true;
        expect(formComponent.isOutcomeButtonEnabled(saveOutcome)).toBeFalsy();
    });
github Alfresco / alfresco-ng2-components / demo-shell / src / app / services / in-memory-form.service.ts View on Github external
parseForm(json: any, data?: FormValues, readOnly: boolean = false): FormModel {
        if (json) {
            const form = new FormModel(json, data, readOnly, this);
            if (!json.fields) {
                form.outcomes = [
                    new FormOutcomeModel(form, {
                        id: '$save',
                        name: FormOutcomeModel.SAVE_ACTION,
                        isSystem: true
                    })
                ];
            }
            return form;
        }
        return null;
    }
github Alfresco / alfresco-ng2-components / lib / process-services / src / lib / form / form.component.spec.ts View on Github external
formComponent.disableCompleteButton = true;

        const field = new FormFieldModel(formModel, {
            type: 'text',
            value: 'text',
            required: true
        });

        const containerModel = new ContainerModel(field);
        formModel.fields.push(containerModel);
        formComponent.form = formModel;
        formModel.onFormFieldChanged(field);

        expect(formModel.isValid).toBeTruthy();

        const completeOutcome = new FormOutcomeModel(new FormModel(), {
            id: FormComponent.COMPLETE_OUTCOME_ID,
            name: FormOutcomeModel.COMPLETE_ACTION
        });

        expect(formModel.isValid).toBeTruthy();

        expect(formComponent.isOutcomeButtonEnabled(completeOutcome)).toBeFalsy();
    });
github Alfresco / alfresco-ng2-components / lib / process-services / src / lib / form / form.component.spec.ts View on Github external
formComponent.disableStartProcessButton = true;

        const field = new FormFieldModel(formModel, {
            type: 'text',
            value: 'text',
            required: true
        });

        const containerModel = new ContainerModel(field);
        formModel.fields.push(containerModel);
        formComponent.form = formModel;
        formModel.onFormFieldChanged(field);

        expect(formModel.isValid).toBeTruthy();

        const startProcessOutcome = new FormOutcomeModel(new FormModel(), {
            id: FormComponent.START_PROCESS_OUTCOME_ID,
            name: FormOutcomeModel.START_PROCESS_ACTION
        });

        expect(formComponent.isOutcomeButtonEnabled(startProcessOutcome)).toBeFalsy();
    });