mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
@@ -1,54 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import {
|
||||
TaskFormService
|
||||
} from '@alfresco/adf-process-services';
|
||||
import { AlfrescoApiService, LogService } from '@alfresco/adf-core';
|
||||
|
||||
@Injectable()
|
||||
export class FakeTaskFormService extends TaskFormService {
|
||||
|
||||
constructor(apiService: AlfrescoApiService, logService: LogService) {
|
||||
super(apiService, logService);
|
||||
}
|
||||
|
||||
public getRestFieldValues(
|
||||
taskId: string,
|
||||
fieldId: string
|
||||
): Observable<any> {
|
||||
if (fieldId === 'typeaheadField') {
|
||||
return of([
|
||||
{ id: '1', name: 'Leanne Graham' },
|
||||
{ id: '2', name: 'Ervin Howell' },
|
||||
{ id: '3', name: 'Clementine Bauch' },
|
||||
{ id: '4', name: 'Patricia Lebsack' },
|
||||
{ id: '5', name: 'Chelsey Dietrich' },
|
||||
{ id: '6', name: 'Mrs. Dennis Schulist' },
|
||||
{ id: '7', name: 'Kurtis Weissnat' },
|
||||
{ id: '8', name: 'Nicholas Runolfsdottir V' },
|
||||
{ id: '9', name: 'Glenna Reichert' },
|
||||
{ id: '10', name: 'Clementina DuBuque' }
|
||||
]);
|
||||
} else {
|
||||
return super.getRestFieldValues(taskId, fieldId);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
<adf-form-list [forms]="formList" (row-dblclick)="onRowDblClick($any($event))">
|
||||
</adf-form-list>
|
||||
<div class="app-form-container" *ngIf="!isEmptyForm()">
|
||||
<adf-form #adfForm [form]="form" [data]="restoredData" [showValidationIcon]="showValidationIcon">
|
||||
</adf-form>
|
||||
</div>
|
||||
<button mat-button (click)="store()">Store</button>
|
||||
<button mat-button (click)="restore()">Restore</button>
|
||||
<section class="app-form-list-margin">
|
||||
<mat-slide-toggle [(ngModel)]="showValidationIcon">Show Validation Icon</mat-slide-toggle>
|
||||
</section>
|
@@ -1,12 +0,0 @@
|
||||
.app-form-container {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.app-store-form-container {
|
||||
width: 80%;
|
||||
height: 80%;
|
||||
}
|
||||
|
||||
.app-form-list-margin {
|
||||
margin-left: 26px;
|
||||
}
|
@@ -1,100 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, ViewChild, OnDestroy, OnInit } from '@angular/core';
|
||||
import { FormModel, FormService, LogService, FormOutcomeEvent } from '@alfresco/adf-core';
|
||||
import { FormComponent, EditorService } from '@alfresco/adf-process-services';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'app-form-list',
|
||||
templateUrl: './form-list.component.html',
|
||||
styleUrls: ['./form-list.component.scss']
|
||||
})
|
||||
export class FormListComponent implements OnInit, OnDestroy {
|
||||
|
||||
@ViewChild('adfForm')
|
||||
activitiForm: FormComponent;
|
||||
|
||||
formList: any [] = [];
|
||||
|
||||
form: FormModel;
|
||||
formId: string;
|
||||
|
||||
storedData: any = {};
|
||||
restoredData: any = {};
|
||||
|
||||
showValidationIcon = false;
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
constructor(private formService: FormService, private editorService: EditorService, private logService: LogService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
// Prevent default outcome actions
|
||||
this.formService.executeOutcome
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.subscribe((formOutcomeEvent: FormOutcomeEvent) => {
|
||||
formOutcomeEvent.preventDefault();
|
||||
this.logService.log(formOutcomeEvent.outcome);
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
onRowDblClick(event: CustomEvent<any>) {
|
||||
const rowForm = event.detail.value.obj;
|
||||
|
||||
this.editorService.getFormDefinitionById(rowForm.id).subscribe((formModel) => {
|
||||
const form = this.formService.parseForm(formModel.formDefinition);
|
||||
this.form = form;
|
||||
});
|
||||
|
||||
this.logService.log(rowForm);
|
||||
}
|
||||
|
||||
isEmptyForm() {
|
||||
return this.form === null || this.form === undefined;
|
||||
}
|
||||
|
||||
store() {
|
||||
this.clone(this.activitiForm.form.values, this.storedData);
|
||||
this.logService.log('DATA SAVED');
|
||||
this.logService.log(this.storedData);
|
||||
this.logService.log('DATA SAVED');
|
||||
this.restoredData = null;
|
||||
}
|
||||
|
||||
clone(objToCopyFrom, objToCopyTo) {
|
||||
for (const attribute in objToCopyFrom) {
|
||||
if (objToCopyFrom.hasOwnProperty(attribute)) {
|
||||
objToCopyTo[attribute] = objToCopyFrom[attribute];
|
||||
}
|
||||
}
|
||||
return objToCopyTo;
|
||||
}
|
||||
|
||||
restore() {
|
||||
this.restoredData = this.storedData;
|
||||
this.storedData = {};
|
||||
}
|
||||
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
<div class="app-form-container">
|
||||
<mat-accordion>
|
||||
<mat-expansion-panel>
|
||||
<mat-expansion-panel-header>
|
||||
<mat-panel-title>Form Data</mat-panel-title>
|
||||
<mat-panel-description>Enter values to populate the form</mat-panel-description>
|
||||
</mat-expansion-panel-header>
|
||||
<mat-list>
|
||||
<mat-list-item>
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="Typeahead" [(ngModel)]="typeaheadFieldValue">
|
||||
</mat-form-field>
|
||||
</mat-list-item>
|
||||
<mat-list-item>
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="DropDown" [(ngModel)]="selectFieldValue">
|
||||
</mat-form-field>
|
||||
</mat-list-item>
|
||||
<mat-list-item>
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="Radio Button" [(ngModel)]="radioButtonFieldValue">
|
||||
</mat-form-field>
|
||||
</mat-list-item>
|
||||
</mat-list>
|
||||
<button mat-button color="primary" (click)="onLoadButtonClicked()">Load</button>
|
||||
</mat-expansion-panel>
|
||||
</mat-accordion>
|
||||
<mat-divider></mat-divider>
|
||||
<adf-form [showRefreshButton]="false" [form]="form" [data]="formattedData">
|
||||
</adf-form>
|
||||
</div>
|
@@ -1,3 +0,0 @@
|
||||
.app-form-container {
|
||||
padding: 10px;
|
||||
}
|
@@ -1,77 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Inject, OnInit, OnDestroy } from '@angular/core';
|
||||
import {
|
||||
FormModel,
|
||||
FormService,
|
||||
FormOutcomeEvent,
|
||||
CoreAutomationService
|
||||
} from '@alfresco/adf-core';
|
||||
import {
|
||||
TaskFormService
|
||||
} from '@alfresco/adf-process-services';
|
||||
import { InMemoryFormService } from '../../services/in-memory-form.service';
|
||||
import { FakeTaskFormService } from './fake-tak-form.service';
|
||||
import { Subject } from 'rxjs';
|
||||
import { takeUntil } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'app-form-loading',
|
||||
templateUrl: './form-loading.component.html',
|
||||
styleUrls: ['./form-loading.component.scss'],
|
||||
providers: [{ provide: FakeTaskFormService, useClass: TaskFormService }]
|
||||
})
|
||||
export class FormLoadingComponent implements OnInit, OnDestroy {
|
||||
form: FormModel;
|
||||
typeaheadFieldValue = '';
|
||||
selectFieldValue = '';
|
||||
radioButtonFieldValue = '';
|
||||
formattedData = {};
|
||||
|
||||
private onDestroy$ = new Subject<boolean>();
|
||||
|
||||
constructor(
|
||||
@Inject(FormService) private formService: InMemoryFormService,
|
||||
private automationService: CoreAutomationService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.formService.executeOutcome
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.subscribe((formOutcomeEvent: FormOutcomeEvent) => {
|
||||
formOutcomeEvent.preventDefault();
|
||||
});
|
||||
|
||||
this.formattedData = {};
|
||||
const formDefinitionJSON: any = this.automationService.forms.getSimpleFormDefinition();
|
||||
this.form = this.formService.parseForm(formDefinitionJSON);
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.onDestroy$.next(true);
|
||||
this.onDestroy$.complete();
|
||||
}
|
||||
|
||||
onLoadButtonClicked() {
|
||||
this.formattedData = {
|
||||
typeaheadField: this.typeaheadFieldValue,
|
||||
selectBox: this.selectFieldValue,
|
||||
radioButton: this.radioButtonFieldValue
|
||||
};
|
||||
}
|
||||
}
|
@@ -1,20 +1,18 @@
|
||||
<div class="main-content">
|
||||
|
||||
<mat-tab-group>
|
||||
<mat-tab-group [animationDuration]="'0'">
|
||||
<mat-tab label="Form">
|
||||
<div class="app-form-container">
|
||||
<adf-form
|
||||
[showRefreshButton]="false"
|
||||
[form]="form"
|
||||
[enableFixedSpacedForm]="keepPrefixedSpace"
|
||||
(formError)="logErrors($event)">
|
||||
</adf-form>
|
||||
</div>
|
||||
|
||||
<div class="app-console" #console>
|
||||
<h3>Error log:</h3>
|
||||
<p *ngFor="let error of errorFields">Error {{ error.name }} {{error.validationSummary.message |
|
||||
translate}}</p>
|
||||
<p *ngFor="let error of errorFields">Error {{ error.name }} {{error.validationSummary.message | translate}}</p>
|
||||
</div>
|
||||
</mat-tab>
|
||||
<mat-tab label="Editor">
|
||||
@@ -26,15 +24,11 @@
|
||||
(onInit)="onInitFormEditor($event)">
|
||||
</ngx-monaco-editor>
|
||||
<div class="app-form-editor-buttons">
|
||||
<button mat-raised-button id="app-form-config-save" (click)="onSaveFormConfig()" color="primary">Save
|
||||
form config
|
||||
</button>
|
||||
<button mat-raised-button id="app-form-config-clear" (click)="onClearFormConfig()" color="primary">Clear
|
||||
form config
|
||||
</button>
|
||||
<button mat-raised-button id="app-form-config-save" (click)="onSaveFormConfig()">Save form config</button>
|
||||
<button mat-raised-button id="app-form-config-clear" (click)="onClearFormConfig()">Clear form config</button>
|
||||
</div>
|
||||
<div class="app-upload-config-button">
|
||||
<a mat-raised-button color="primary" >
|
||||
<a mat-raised-button>
|
||||
<mat-icon>file_upload</mat-icon>
|
||||
<label for="upload-config-file">Upload JSON File</label>
|
||||
<input
|
||||
@@ -46,14 +40,7 @@
|
||||
(change)="onConfigAdded($event)">
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</mat-tab>
|
||||
<mat-tab label="Options">
|
||||
<mat-slide-toggle [checked]="keepPrefixedSpace" (change)="togglePrefixedSpace()" >
|
||||
Keep prefixed space for hidden field
|
||||
</mat-slide-toggle>
|
||||
</mat-tab>
|
||||
|
||||
</mat-tab-group>
|
||||
</div>
|
||||
|
||||
|
@@ -33,12 +33,10 @@ import { takeUntil } from 'rxjs/operators';
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class FormComponent implements OnInit, OnDestroy {
|
||||
|
||||
form: FormModel;
|
||||
errorFields: FormFieldModel[] = [];
|
||||
formConfig: string;
|
||||
editor: any;
|
||||
keepPrefixedSpace = true;
|
||||
|
||||
editorOptions = {
|
||||
theme: 'vs-dark',
|
||||
@@ -86,7 +84,7 @@ export class FormComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
parseForm() {
|
||||
this.form = this.formService.parseForm(JSON.parse(this.formConfig), null, false, this.keepPrefixedSpace);
|
||||
this.form = this.formService.parseForm(JSON.parse(this.formConfig), null, false, true);
|
||||
}
|
||||
|
||||
onSaveFormConfig() {
|
||||
@@ -114,8 +112,4 @@ export class FormComponent implements OnInit, OnDestroy {
|
||||
|
||||
$event.target.value = '';
|
||||
}
|
||||
|
||||
togglePrefixedSpace() {
|
||||
this.keepPrefixedSpace = !this.keepPrefixedSpace;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user