mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
cleaning
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
<div class="activiti-form-viewer" *ngIf="taskId">
|
<div class="activiti-form-viewer" *ngIf="taskId">
|
||||||
<activiti-form [formName]="'Health_User_Form'"></activiti-form>
|
<activiti-form [formName]="'hc:patientFolder'" [saveMetadata]="true"></activiti-form>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -94,6 +94,9 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
|
|||||||
@Input()
|
@Input()
|
||||||
formName: string;
|
formName: string;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
saveMetadata: boolean = false;
|
||||||
|
|
||||||
@Input()
|
@Input()
|
||||||
data: FormValues;
|
data: FormValues;
|
||||||
|
|
||||||
@@ -163,7 +166,7 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.nodeId) {
|
if (this.nodeId) {
|
||||||
this.retriveNodeMetadataFromEcm();
|
this.loadFormForEcmMetadata();
|
||||||
} else {
|
} else {
|
||||||
this.loadForm();
|
this.loadForm();
|
||||||
}
|
}
|
||||||
@@ -220,6 +223,7 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
|
|||||||
|
|
||||||
if (outcome.id === ActivitiForm.CUSTOM_OUTCOME_ID) {
|
if (outcome.id === ActivitiForm.CUSTOM_OUTCOME_ID) {
|
||||||
this.formSaved.emit(this.form);
|
this.formSaved.emit(this.form);
|
||||||
|
this.storeFormAsMetadata();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -277,7 +281,6 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
|
|||||||
form => {
|
form => {
|
||||||
this.form = new FormModel(form, data, this.readOnly);
|
this.form = new FormModel(form, data, this.readOnly);
|
||||||
this.formLoaded.emit(this.form);
|
this.formLoaded.emit(this.form);
|
||||||
this.isActivitiModelExisting();
|
|
||||||
},
|
},
|
||||||
this.handleError
|
this.handleError
|
||||||
);
|
);
|
||||||
@@ -291,7 +294,6 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
|
|||||||
// console.log('Get Form By definition Id', form);
|
// console.log('Get Form By definition Id', form);
|
||||||
this.form = this.parseForm(form);
|
this.form = this.parseForm(form);
|
||||||
this.formLoaded.emit(this.form);
|
this.formLoaded.emit(this.form);
|
||||||
this.isActivitiModelExisting();
|
|
||||||
},
|
},
|
||||||
this.handleError
|
this.handleError
|
||||||
);
|
);
|
||||||
@@ -307,7 +309,6 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
|
|||||||
// console.log('Get Form By Form definition Name', form);
|
// console.log('Get Form By Form definition Name', form);
|
||||||
this.form = this.parseForm(form);
|
this.form = this.parseForm(form);
|
||||||
this.formLoaded.emit(this.form);
|
this.formLoaded.emit(this.form);
|
||||||
this.isActivitiModelExisting();
|
|
||||||
},
|
},
|
||||||
this.handleError
|
this.handleError
|
||||||
);
|
);
|
||||||
@@ -321,7 +322,10 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
|
|||||||
this.formService
|
this.formService
|
||||||
.saveTaskForm(this.form.taskId, this.form.values)
|
.saveTaskForm(this.form.taskId, this.form.values)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
() => this.formSaved.emit(this.form),
|
() => {
|
||||||
|
this.formSaved.emit(this.form);
|
||||||
|
this.storeFormAsMetadata();
|
||||||
|
},
|
||||||
this.handleError
|
this.handleError
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -332,7 +336,10 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
|
|||||||
this.formService
|
this.formService
|
||||||
.completeTaskForm(this.form.taskId, this.form.values, outcome)
|
.completeTaskForm(this.form.taskId, this.form.values, outcome)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
() => this.formCompleted.emit(this.form),
|
() => {
|
||||||
|
this.formCompleted.emit(this.form);
|
||||||
|
this.storeFormAsMetadata();
|
||||||
|
},
|
||||||
this.handleError
|
this.handleError
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -370,7 +377,7 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private retriveNodeMetadataFromEcm(): void {
|
private loadFormForEcmMetadata(): void {
|
||||||
let metadata = {};
|
let metadata = {};
|
||||||
let self = this;
|
let self = this;
|
||||||
this.authService.getAlfrescoApi().nodes.getNodeInfo(this.nodeId).then(function (data) {
|
this.authService.getAlfrescoApi().nodes.getNodeInfo(this.nodeId).then(function (data) {
|
||||||
@@ -502,26 +509,47 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private isActivitiModelExisting() {
|
private storeFormAsMetadata() {
|
||||||
|
if (this.saveMetadata) {
|
||||||
let modelName = 'activitiForms';
|
let modelName = 'activitiForms';
|
||||||
|
|
||||||
|
|
||||||
this.getEcmModels().subscribe(
|
this.getEcmModels().subscribe(
|
||||||
models => {
|
models => {
|
||||||
console.log('models', models);
|
if (!this.isAnEcmModelExistingForThisForm(models, modelName)) {
|
||||||
let formEcmModel =
|
let modelNamespace = 'activitiFormsModel';
|
||||||
models.list.entries.find(model => model.entry.name === modelName);
|
this.createAndActiveEcmModel(modelName, modelNamespace);
|
||||||
if (!formEcmModel) {
|
} else {
|
||||||
let namespace = 'activitiFormsModel';
|
this.createModelType(modelName);
|
||||||
this.createEcmModel(modelName, namespace).subscribe(
|
}
|
||||||
|
},
|
||||||
|
this.handleError
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private createAndActiveEcmModel(modelName: string, modelNamespace: string) {
|
||||||
|
this.createEcmModel(modelName, modelNamespace).subscribe(
|
||||||
model => {
|
model => {
|
||||||
console.log('model created', model);
|
console.log('model created', model);
|
||||||
|
|
||||||
this.activeEcmModel(modelName).subscribe(
|
this.activeEcmModel(modelName).subscribe(
|
||||||
modelActive => {
|
modelActive => {
|
||||||
console.log('model active', modelActive);
|
console.log('model active', modelActive);
|
||||||
|
this.createModelType(modelName);
|
||||||
|
},
|
||||||
|
this.handleError
|
||||||
|
);
|
||||||
|
},
|
||||||
|
this.handleError
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
this.getCustomTypes(modelName).subscribe(
|
private createModelType(modelName: string) {
|
||||||
|
this.getEcmTypes(modelName).subscribe(
|
||||||
customTypes => {
|
customTypes => {
|
||||||
console.log('custom types', modelActive);
|
console.log('custom types', customTypes);
|
||||||
|
|
||||||
let customType = customTypes.list.entries.find(type => type.entry.name === this.formName);
|
let customType = customTypes.list.entries.find(type => type.entry.name === this.formName);
|
||||||
if (!customType) {
|
if (!customType) {
|
||||||
@@ -541,18 +569,15 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
|
|||||||
},
|
},
|
||||||
this.handleError
|
this.handleError
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
this.handleError
|
|
||||||
);
|
|
||||||
},
|
|
||||||
this.handleError
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
this.handleError
|
private isAnEcmModelExistingForThisForm(ecmModels: any, modelName: string) {
|
||||||
);
|
let formEcmModel = ecmModels.list.entries.find(model => model.entry.name === modelName);
|
||||||
|
if (!formEcmModel) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private activeEcmModel(modelName: string): Observable<any> {
|
private activeEcmModel(modelName: string): Observable<any> {
|
||||||
@@ -594,7 +619,7 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private getCustomTypes(modelName: string): Observable<any> {
|
private getEcmTypes(modelName: string): Observable<any> {
|
||||||
let url = `${this.alfrescoSettingsService.ecmHost}/alfresco/api/-default-/private/alfresco/versions/1/cmm/${modelName}/types`;
|
let url = `${this.alfrescoSettingsService.ecmHost}/alfresco/api/-default-/private/alfresco/versions/1/cmm/${modelName}/types`;
|
||||||
let options = this.getRequestOptions();
|
let options = this.getRequestOptions();
|
||||||
|
|
||||||
@@ -626,25 +651,26 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
|
|||||||
let url = `${this.alfrescoSettingsService.ecmHost}/alfresco/api/-default-/private/alfresco/versions/1/cmm/${modelName}/types/${typeName}?select=props`;
|
let url = `${this.alfrescoSettingsService.ecmHost}/alfresco/api/-default-/private/alfresco/versions/1/cmm/${modelName}/types/${typeName}?select=props`;
|
||||||
let options = this.getRequestOptions();
|
let options = this.getRequestOptions();
|
||||||
|
|
||||||
if (formFields) {
|
let properties = [];
|
||||||
for (let key in formFields) {
|
if (formFields && formFields.values) {
|
||||||
|
for (let key in formFields.values) {
|
||||||
if (key) {
|
if (key) {
|
||||||
console.log(key + ' => ' + formFields[key]);
|
properties.push({
|
||||||
|
name: key,
|
||||||
|
title: key,
|
||||||
|
description: key,
|
||||||
|
dataType: 'd:text',
|
||||||
|
multiValued: false,
|
||||||
|
mandatory: false,
|
||||||
|
mandatoryEnforced: false
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let body = {
|
let body = {
|
||||||
name: 'myAspect1',
|
name: typeName,
|
||||||
properties: [{
|
properties: properties
|
||||||
name: 'InvoiceNumber',
|
|
||||||
title: 'Invoice Number',
|
|
||||||
description: 'MyProperty desc',
|
|
||||||
dataType: 'd:text',
|
|
||||||
multiValued: false,
|
|
||||||
mandatory: false,
|
|
||||||
mandatoryEnforced: false
|
|
||||||
}]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.http
|
return this.http
|
||||||
@@ -657,7 +683,7 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
|
|||||||
return new Headers({
|
return new Headers({
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Authorization': this.authService.getTicketEcm()
|
'Authorization': this.authService.getTicketEcmBase64()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user