How to use the @alfresco/adf-core.FormModel 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 check visibility only if field with form provided', () => {

        formComponent.checkVisibility(null);
        expect(visibilityService.refreshVisibility).not.toHaveBeenCalled();

        let field = new FormFieldModel(null);
        formComponent.checkVisibility(field);
        expect(visibilityService.refreshVisibility).not.toHaveBeenCalled();

        field = new FormFieldModel(new FormModel());
        formComponent.checkVisibility(field);
        expect(visibilityService.refreshVisibility).toHaveBeenCalledWith(field.form);
    });
github Alfresco / alfresco-ng2-components / lib / process-services / src / lib / form / form.component.spec.ts View on Github external
it('should disable outcome buttons for invalid form', () => {
        const formModel = new FormModel();
        const field = new FormFieldModel(formModel, {
            type: 'text',
            value: null,
            required: true
        });

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

        expect(formModel.isValid).toBeFalsy();

        const outcome = new FormOutcomeModel(new FormModel(), {
            id: FormComponent.CUSTOM_OUTCOME_ID,
            name: 'Custom'
github Alfresco / alfresco-ng2-components / lib / process-services / src / lib / form / form.component.spec.ts View on Github external
it('should save task form and raise corresponding event', () => {
        spyOn(formService, 'saveTaskForm').and.callFake(() => {
            return new Observable((observer) => {
                observer.next();
                observer.complete();
            });
        });

        let saved = false;
        let savedForm = null;
        formComponent.formSaved.subscribe((form) => {
            saved = true;
            savedForm = form;
        });

        const formModel = new FormModel({
            taskId: '123',
            fields: [
                { id: 'field1' },
                { id: 'field2' }
            ]
        });
        formComponent.form = formModel;
        formComponent.saveTaskForm();

        expect(formService.saveTaskForm).toHaveBeenCalledWith(formModel.taskId, formModel.values);
        expect(saved).toBeTruthy();
        expect(savedForm).toEqual(formModel);
    });
github Alfresco / alfresco-ng2-components / lib / process-services / src / lib / form / form.component.spec.ts View on Github external
it('should disable save outcome button when form is valid and readOnly', () => {
        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,
github Alfresco / alfresco-ng2-components / lib / process-services / src / lib / form / form.component.spec.ts View on Github external
it('should require loaded form when clicking outcome', () => {
        const formModel = new FormModel();
        const outcomeName = 'Custom Action';
        const outcome = new FormOutcomeModel(formModel, { id: 'custom1', name: outcomeName });

        formComponent.readOnly = false;
        formComponent.form = null;
        expect(formComponent.onOutcomeClicked(outcome)).toBeFalsy();
    });
github Alfresco / alfresco-ng2-components / lib / process-services / src / lib / task-list / components / start-task.component.ts View on Github external
ngOnInit() {
        if (this.name) {
            this.taskDetailsModel.name = this.name;
        }

        this.validateMaxTaskNameLength();

        this.field = new FormFieldModel(new FormModel(), { id: this.assigneeId, value: this.assigneeId, placeholder: 'Assignee' });

        this.userPreferencesService
            .select(UserPreferenceValues.Locale)
            .pipe(takeUntil(this.onDestroy$))
            .subscribe(locale => this.dateAdapter.setLocale(locale));

        this.loadFormsTask();
        this.buildForm();
    }
github Alfresco / alfresco-ng2-components / lib / process-services / src / lib / form / form.component.spec.ts View on Github external
it('should disable custom outcome buttons for readonly form', () => {
        const formModel = new FormModel();
        formModel.readOnly = true;
        formComponent.form = formModel;

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

        expect(formComponent.isOutcomeButtonEnabled(outcome)).toBeFalsy();
    });
github Alfresco / alfresco-ng2-components / lib / process-services / src / lib / form / form.component.ts View on Github external
parseForm(formRepresentationJSON: any): FormModel {
        if (formRepresentationJSON) {
            const form = new FormModel(formRepresentationJSON, this.data, this.readOnly, this.formService);
            if (!formRepresentationJSON.fields) {
                form.outcomes = this.getFormDefinitionOutcomes(form);
            }
            if (this.fieldValidators && this.fieldValidators.length > 0) {
                form.fieldValidators = this.fieldValidators;
            }
            return form;
        }
        return null;
    }
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;
    }