mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-08-07 17:48:54 +00:00
committed by
Eugenio Romano
parent
8959476941
commit
0b246b8211
@@ -22,7 +22,6 @@ import { ContentLinkModel } from './widgets/core/content-link.model';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'activiti-content',
|
||||
templateUrl: './activiti-content.component.html',
|
||||
styleUrls: ['./activiti-content.component.css']
|
||||
@@ -44,6 +43,9 @@ export class ActivitiContent implements OnChanges {
|
||||
@Output()
|
||||
contentLoaded: EventEmitter<any> = new EventEmitter<any>();
|
||||
|
||||
@Output()
|
||||
error: EventEmitter<any> = new EventEmitter<any>();
|
||||
|
||||
content: ContentLinkModel;
|
||||
|
||||
constructor(private translate: AlfrescoTranslationService,
|
||||
@@ -71,8 +73,8 @@ export class ActivitiContent implements OnChanges {
|
||||
this.contentLoaded.emit(this.content);
|
||||
this.loadThumbnailUrl(this.content);
|
||||
},
|
||||
error => {
|
||||
this.logService.error(error);
|
||||
(error) => {
|
||||
this.error.emit(error);
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -93,8 +95,9 @@ export class ActivitiContent implements OnChanges {
|
||||
this.content.thumbnailUrl = this.contentService.createTrustedUrl(response);
|
||||
this.thumbnailLoaded.emit(this.content.thumbnailUrl);
|
||||
},
|
||||
error => {
|
||||
this.logService.error(error);
|
||||
(error) => {
|
||||
this.error.emit(error);
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -109,7 +112,9 @@ export class ActivitiContent implements OnChanges {
|
||||
this.logService.info('Content clicked' + content.id);
|
||||
this.formService.formContentClicked.next(content);
|
||||
},
|
||||
error => this.logService.error(error)
|
||||
(error) => {
|
||||
this.error.emit(error);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -119,7 +124,9 @@ export class ActivitiContent implements OnChanges {
|
||||
download(content: ContentLinkModel): void {
|
||||
this.formService.getFileRawContent(content.id).subscribe(
|
||||
(blob: Blob) => this.contentService.downloadBlob(blob, content.name),
|
||||
error => this.logService.error(error)
|
||||
(error) => {
|
||||
this.error.emit(error);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -71,7 +71,6 @@ declare var componentHandler: any;
|
||||
* @returns {ActivitiForm} .
|
||||
*/
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'activiti-form',
|
||||
templateUrl: './activiti-form.component.html',
|
||||
styleUrls: ['./activiti-form.component.css']
|
||||
@@ -238,6 +237,12 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
|
||||
this.getFormDefinitionByFormName(formName.currentValue);
|
||||
return;
|
||||
}
|
||||
|
||||
let nodeId = changes['nodeId'];
|
||||
if (nodeId && nodeId.currentValue) {
|
||||
this.loadFormForEcmNode();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -431,7 +436,6 @@ export class ActivitiForm implements OnInit, AfterViewChecked, OnChanges {
|
||||
}
|
||||
|
||||
handleError(err: any): any {
|
||||
this.logService.error(err);
|
||||
this.onError.emit(err);
|
||||
}
|
||||
|
||||
|
@@ -51,7 +51,6 @@ import { ContentLinkModel } from './widgets/core/content-link.model';
|
||||
* @returns {ActivitiForm} .
|
||||
*/
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'activiti-start-form',
|
||||
templateUrl: './activiti-start-form.component.html',
|
||||
styleUrls: ['./activiti-form.component.css']
|
||||
|
@@ -19,7 +19,6 @@ import { Component, OnInit } from '@angular/core';
|
||||
import { WidgetComponent } from './../widget.component';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'amount-widget',
|
||||
templateUrl: './amount.widget.html',
|
||||
styleUrls: ['./amount.widget.css']
|
||||
|
@@ -38,7 +38,8 @@ describe('AttachWidget', () => {
|
||||
|
||||
dialogPolyfill = {
|
||||
registerDialog(obj: any) {
|
||||
obj.showModal = function () {};
|
||||
obj.showModal = function () {
|
||||
};
|
||||
}
|
||||
};
|
||||
window['dialogPolyfill'] = dialogPolyfill;
|
||||
@@ -58,7 +59,7 @@ describe('AttachWidget', () => {
|
||||
|
||||
widget.field = new FormFieldModel(null, {
|
||||
type: FormFieldTypes.UPLOAD,
|
||||
value: [{ name: 'file' }]
|
||||
value: [{name: 'file'}]
|
||||
});
|
||||
widget.ngOnInit();
|
||||
expect(widget.hasFile()).toBeTruthy();
|
||||
@@ -68,8 +69,8 @@ describe('AttachWidget', () => {
|
||||
let nodes = [{}];
|
||||
spyOn(contentService, 'getAlfrescoNodes').and.returnValue(
|
||||
Observable.create(observer => {
|
||||
observer.next(nodes);
|
||||
observer.complete();
|
||||
observer.next(nodes);
|
||||
observer.complete();
|
||||
})
|
||||
);
|
||||
|
||||
@@ -124,7 +125,7 @@ describe('AttachWidget', () => {
|
||||
it('should reset', () => {
|
||||
widget.field = new FormFieldModel(null, {
|
||||
type: FormFieldTypes.UPLOAD,
|
||||
value: [{ name: 'filename' }]
|
||||
value: [{name: 'filename'}]
|
||||
});
|
||||
|
||||
widget.reset();
|
||||
@@ -138,7 +139,7 @@ describe('AttachWidget', () => {
|
||||
let closed = false;
|
||||
widget.dialog = {
|
||||
nativeElement: {
|
||||
close: function() {
|
||||
close: function () {
|
||||
closed = true;
|
||||
}
|
||||
}
|
||||
@@ -150,8 +151,8 @@ describe('AttachWidget', () => {
|
||||
it('should show modal dialog', () => {
|
||||
spyOn(contentService, 'getAlfrescoNodes').and.returnValue(
|
||||
Observable.create(observer => {
|
||||
observer.next([]);
|
||||
observer.complete();
|
||||
observer.next([]);
|
||||
observer.complete();
|
||||
})
|
||||
);
|
||||
|
||||
@@ -167,7 +168,7 @@ describe('AttachWidget', () => {
|
||||
let modalShown = false;
|
||||
widget.dialog = {
|
||||
nativeElement: {
|
||||
showModal: function() {
|
||||
showModal: function () {
|
||||
modalShown = true;
|
||||
}
|
||||
}
|
||||
@@ -181,12 +182,12 @@ describe('AttachWidget', () => {
|
||||
let nodes = [{}];
|
||||
spyOn(contentService, 'getAlfrescoNodes').and.returnValue(
|
||||
Observable.create(observer => {
|
||||
observer.next(nodes);
|
||||
observer.complete();
|
||||
observer.next(nodes);
|
||||
observer.complete();
|
||||
})
|
||||
);
|
||||
|
||||
let node = <ExternalContent> { id: '<id>' };
|
||||
let node = <ExternalContent> {id: '<id>'};
|
||||
widget.selectFolder(node, null);
|
||||
|
||||
expect(widget.selectedFolderPathId).toBe(node.id);
|
||||
@@ -202,7 +203,7 @@ describe('AttachWidget', () => {
|
||||
|
||||
it('should get linked file name via selected file', () => {
|
||||
widget.fileName = null;
|
||||
widget.selectedFile = <ExternalContent> { title: '<title>' };
|
||||
widget.selectedFile = <ExternalContent> {title: '<title>'};
|
||||
widget.field = null;
|
||||
expect(widget.getLinkedFileName()).toBe(widget.selectedFile.title);
|
||||
});
|
||||
@@ -214,7 +215,7 @@ describe('AttachWidget', () => {
|
||||
let name = '<file>';
|
||||
widget.field = new FormFieldModel(null, {
|
||||
type: FormFieldTypes.UPLOAD,
|
||||
value: [{ name: name }]
|
||||
value: [{name: name}]
|
||||
});
|
||||
|
||||
expect(widget.getLinkedFileName()).toBe(name);
|
||||
@@ -250,8 +251,8 @@ describe('AttachWidget', () => {
|
||||
let nodes = [{}];
|
||||
spyOn(contentService, 'getAlfrescoNodes').and.returnValue(
|
||||
Observable.create(observer => {
|
||||
observer.next(nodes);
|
||||
observer.complete();
|
||||
observer.next(nodes);
|
||||
observer.complete();
|
||||
})
|
||||
);
|
||||
|
||||
@@ -265,15 +266,17 @@ describe('AttachWidget', () => {
|
||||
expect(widget.selectedFolderNodes).toEqual(nodes);
|
||||
});
|
||||
|
||||
it('should handle error', () => {
|
||||
it('should handle error', (done) => {
|
||||
let error = 'error';
|
||||
spyOn(contentService, 'getAlfrescoNodes').and.returnValue(
|
||||
Observable.throw(error)
|
||||
);
|
||||
|
||||
spyOn(logService, 'error').and.stub();
|
||||
widget.error.subscribe(() => {
|
||||
done();
|
||||
});
|
||||
|
||||
widget.getExternalContentNodes();
|
||||
expect(logService.error).toHaveBeenCalledWith(error);
|
||||
});
|
||||
|
||||
it('should register dialog via polyfill', () => {
|
||||
|
@@ -26,7 +26,6 @@ import { FormFieldModel } from '../core/form-field.model';
|
||||
declare let dialogPolyfill: any;
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'attach-widget',
|
||||
templateUrl: './attach.widget.html',
|
||||
styleUrls: ['./attach.widget.css']
|
||||
@@ -47,6 +46,9 @@ export class AttachWidget extends WidgetComponent implements OnInit {
|
||||
@Output()
|
||||
fieldChanged: EventEmitter<FormFieldModel> = new EventEmitter<FormFieldModel>();
|
||||
|
||||
@Output()
|
||||
error: EventEmitter<any> = new EventEmitter<any>();
|
||||
|
||||
@ViewChild('dialog')
|
||||
dialog: any;
|
||||
|
||||
@@ -99,7 +101,9 @@ export class AttachWidget extends WidgetComponent implements OnInit {
|
||||
this.contentService.getAlfrescoNodes(this.selectedFolderAccountId, this.selectedFolderPathId)
|
||||
.subscribe(
|
||||
nodes => this.selectedFolderNodes = nodes,
|
||||
error => this.logService.error(error)
|
||||
(err) => {
|
||||
this.error.emit(err);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -20,7 +20,6 @@ import { WidgetComponent } from './../widget.component';
|
||||
import { WidgetVisibilityService } from '../../../services/widget-visibility.service';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'checkbox-widget',
|
||||
templateUrl: './checkbox.widget.html'
|
||||
})
|
||||
|
@@ -22,7 +22,6 @@ import { WidgetComponent } from './../widget.component';
|
||||
declare var componentHandler: any;
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'container-widget',
|
||||
templateUrl: './container.widget.html',
|
||||
styleUrls: ['./container.widget.css']
|
||||
|
@@ -23,7 +23,6 @@ declare let mdDateTimePicker: any;
|
||||
declare var componentHandler: any;
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'date-widget',
|
||||
templateUrl: './date.widget.html',
|
||||
styleUrls: ['./date.widget.css']
|
||||
|
@@ -19,7 +19,6 @@ import { Component } from '@angular/core';
|
||||
import { WidgetComponent } from './../widget.component';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'display-text-widget',
|
||||
templateUrl: './display-text.widget.html',
|
||||
styleUrls: ['./display-text.widget.css']
|
||||
|
@@ -39,7 +39,7 @@ describe('DisplayValueWidget', () => {
|
||||
logService = new LogServiceMock();
|
||||
formService = new FormService(null, null, logService);
|
||||
visibilityService = new WidgetVisibilityService(null, logService);
|
||||
widget = new DisplayValueWidget(formService, visibilityService, logService);
|
||||
widget = new DisplayValueWidget(formService, visibilityService);
|
||||
});
|
||||
|
||||
it('should require field to setup default value', () => {
|
||||
@@ -387,14 +387,12 @@ describe('DisplayValueWidget', () => {
|
||||
expect(widget.value).toBe('100');
|
||||
});
|
||||
|
||||
it('should handle rest error', () => {
|
||||
it('should handle rest error', (done) => {
|
||||
const error = 'ERROR';
|
||||
spyOn(formService, 'getRestFieldValues').and.returnValue(
|
||||
Observable.throw(error)
|
||||
);
|
||||
|
||||
spyOn(logService, 'error').and.stub();
|
||||
|
||||
let form = new FormModel({taskId: '<id>'});
|
||||
|
||||
widget.field = new FormFieldModel(form, {
|
||||
@@ -407,10 +405,12 @@ describe('DisplayValueWidget', () => {
|
||||
}
|
||||
}
|
||||
});
|
||||
widget.error.subscribe(() => {
|
||||
expect(formService.getRestFieldValues).toHaveBeenCalled();
|
||||
expect(widget.value).toBe('100');
|
||||
done();
|
||||
});
|
||||
widget.ngOnInit();
|
||||
expect(formService.getRestFieldValues).toHaveBeenCalled();
|
||||
expect(logService.error).toHaveBeenCalledWith(error);
|
||||
expect(widget.value).toBe('100');
|
||||
});
|
||||
|
||||
it('should setup [DATE] field with valid date', () => {
|
||||
|
@@ -15,9 +15,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, Output, EventEmitter } from '@angular/core';
|
||||
import * as moment from 'moment';
|
||||
import { LogService } from 'ng2-alfresco-core';
|
||||
import { WidgetComponent } from './../widget.component';
|
||||
import { FormFieldTypes } from '../core/form-field-types';
|
||||
import { FormService } from '../../../services/form.service';
|
||||
@@ -26,13 +25,15 @@ import { WidgetVisibilityService } from '../../../services/widget-visibility.ser
|
||||
import { NumberFieldValidator } from '../core/form-field-validator';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'display-value-widget',
|
||||
templateUrl: './display-value.widget.html',
|
||||
styleUrls: ['./display-value.widget.css']
|
||||
})
|
||||
export class DisplayValueWidget extends WidgetComponent implements OnInit {
|
||||
|
||||
@Output()
|
||||
error: EventEmitter<any> = new EventEmitter<any>();
|
||||
|
||||
value: any;
|
||||
fieldType: string;
|
||||
id: any;
|
||||
@@ -49,8 +50,7 @@ export class DisplayValueWidget extends WidgetComponent implements OnInit {
|
||||
showDocumentContent: boolean = true;
|
||||
|
||||
constructor(private formService: FormService,
|
||||
private visibilityService: WidgetVisibilityService,
|
||||
private logService: LogService) {
|
||||
private visibilityService: WidgetVisibilityService) {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -185,8 +185,7 @@ export class DisplayValueWidget extends WidgetComponent implements OnInit {
|
||||
}
|
||||
this.visibilityService.refreshVisibility(this.field.form);
|
||||
},
|
||||
error => {
|
||||
this.logService.error(error);
|
||||
(error) => {
|
||||
this.value = this.field.value;
|
||||
}
|
||||
);
|
||||
@@ -207,8 +206,8 @@ export class DisplayValueWidget extends WidgetComponent implements OnInit {
|
||||
}
|
||||
this.visibilityService.refreshVisibility(this.field.form);
|
||||
},
|
||||
error => {
|
||||
this.logService.error(error);
|
||||
(error) => {
|
||||
this.error.emit(error);
|
||||
this.value = this.field.value;
|
||||
}
|
||||
);
|
||||
|
@@ -23,7 +23,6 @@ import { FormFieldOption } from './../core/form-field-option';
|
||||
import { WidgetVisibilityService } from '../../../services/widget-visibility.service';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'dropdown-widget',
|
||||
templateUrl: './dropdown.widget.html',
|
||||
styleUrls: ['./dropdown.widget.css']
|
||||
|
@@ -23,7 +23,6 @@ import { WidgetVisibilityService } from '../../../services/widget-visibility.ser
|
||||
import { FormFieldModel } from '../core/form-field.model';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'dynamic-table-widget',
|
||||
templateUrl: './dynamic-table.widget.html',
|
||||
styleUrls: ['./dynamic-table.widget.css']
|
||||
|
@@ -19,7 +19,6 @@ import { Component, Input } from '@angular/core';
|
||||
import { DynamicTableModel, DynamicTableRow, DynamicTableColumn } from './../../dynamic-table.widget.model';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'alf-boolean-editor',
|
||||
templateUrl: './boolean.editor.html',
|
||||
styleUrls: ['./boolean.editor.css']
|
||||
|
@@ -22,7 +22,6 @@ import * as moment from 'moment';
|
||||
declare let mdDateTimePicker: any;
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'alf-date-editor',
|
||||
templateUrl: './date.editor.html',
|
||||
styleUrls: ['./date.editor.css']
|
||||
|
@@ -21,7 +21,6 @@ import { DynamicTableModel, DynamicTableRow, DynamicTableColumn, DynamicTableCol
|
||||
import { FormService } from './../../../../../services/form.service';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'alf-dropdown-editor',
|
||||
templateUrl: './dropdown.editor.html',
|
||||
styleUrls: ['./dropdown.editor.css']
|
||||
|
@@ -19,7 +19,6 @@ import { Component, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { DynamicTableModel, DynamicTableRow, DynamicTableColumn, DynamicRowValidationSummary } from './../dynamic-table.widget.model';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'row-editor',
|
||||
templateUrl: './row.editor.html',
|
||||
styleUrls: ['./row.editor.css']
|
||||
|
@@ -19,7 +19,6 @@ import { Component, Input, OnInit } from '@angular/core';
|
||||
import { DynamicTableRow, DynamicTableColumn, DynamicTableModel } from './../../dynamic-table.widget.model';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'alf-text-editor',
|
||||
templateUrl: './text.editor.html',
|
||||
styleUrls: ['./text.editor.css']
|
||||
|
@@ -21,7 +21,6 @@ import { FormService } from '../../../services/form.service';
|
||||
import { GroupModel } from './../core/group.model';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'functional-group-widget',
|
||||
templateUrl: './functional-group.widget.html',
|
||||
styleUrls: ['./functional-group.widget.css']
|
||||
|
@@ -19,7 +19,6 @@ import { Component, OnInit } from '@angular/core';
|
||||
import { WidgetComponent } from './../widget.component';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'hyperlink-widget',
|
||||
templateUrl: './hyperlink.widget.html',
|
||||
styleUrls: ['./hyperlink.widget.css']
|
||||
|
@@ -19,7 +19,6 @@ import { Component } from '@angular/core';
|
||||
import { WidgetComponent } from './../widget.component';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'multiline-text-widget',
|
||||
templateUrl: './multiline-text.widget.html',
|
||||
styleUrls: ['./multiline-text.widget.css']
|
||||
|
@@ -19,7 +19,6 @@ import { Component } from '@angular/core';
|
||||
import { WidgetComponent } from './../widget.component';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'number-widget',
|
||||
templateUrl: './number.widget.html',
|
||||
styleUrls: ['./number.widget.css']
|
||||
|
@@ -22,7 +22,6 @@ import { GroupModel } from '../core/group.model';
|
||||
import { GroupUserModel } from '../core/group-user.model';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'people-widget',
|
||||
templateUrl: './people.widget.html',
|
||||
styleUrls: ['./people.widget.css']
|
||||
|
@@ -23,7 +23,6 @@ import { FormFieldOption } from './../core/form-field-option';
|
||||
import { WidgetVisibilityService } from '../../../services/widget-visibility.service';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'radio-buttons-widget',
|
||||
templateUrl: './radio-buttons.widget.html',
|
||||
styleUrls: ['./radio-buttons.widget.css']
|
||||
|
@@ -21,7 +21,6 @@ import { TabModel, FormFieldModel } from './../core/index';
|
||||
declare var componentHandler: any;
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'tabs-widget',
|
||||
templateUrl: './tabs.widget.html'
|
||||
})
|
||||
|
@@ -19,7 +19,6 @@ import { Component } from '@angular/core';
|
||||
import { WidgetComponent } from './../widget.component';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'text-widget',
|
||||
templateUrl: './text.widget.html',
|
||||
styleUrls: ['./text.widget.css']
|
||||
|
@@ -23,7 +23,6 @@ import { FormFieldOption } from './../core/form-field-option';
|
||||
import { WidgetVisibilityService } from '../../../services/widget-visibility.service';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'typeahead-widget',
|
||||
templateUrl: './typeahead.widget.html',
|
||||
styleUrls: ['./typeahead.widget.css']
|
||||
|
@@ -21,7 +21,6 @@ import { WidgetComponent } from './../widget.component';
|
||||
import { FormService } from '../../../services/form.service';
|
||||
|
||||
@Component({
|
||||
moduleId: module.id,
|
||||
selector: 'upload-widget',
|
||||
templateUrl: './upload.widget.html',
|
||||
styleUrls: ['./upload.widget.css']
|
||||
@@ -69,8 +68,7 @@ export class UploadWidget extends WidgetComponent implements OnInit {
|
||||
this.field.value = [response];
|
||||
this.field.json.value = [response];
|
||||
}, (error: any) => {
|
||||
this.logService.error(error);
|
||||
window.alert('Error uploading file. See console output for more details.');
|
||||
this.logService.error('Error uploading file. See console output for more details.');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user