diff --git a/demo-shell-ng2/app/components/files/files.component.ts b/demo-shell-ng2/app/components/files/files.component.ts index 6d3cac70b3..88783fba5f 100644 --- a/demo-shell-ng2/app/components/files/files.component.ts +++ b/demo-shell-ng2/app/components/files/files.component.ts @@ -21,7 +21,9 @@ import { DOCUMENT_LIST_PROVIDERS, DocumentActionsService, DocumentList, - ContentActionModel, ContentActionHandler + ContentActionHandler, + DocumentActionModel, + FolderActionModel } from 'ng2-alfresco-documentlist'; import { MDL, @@ -129,14 +131,16 @@ export class FilesComponent implements OnInit { private setupBpmActions(actions: any[]) { actions.map(def => { - let action = new ContentActionModel(); - action.target = 'document'; - action.title = 'Activiti: ' + (def.name || 'Unknown process'); - action.handler = this.getBpmActionHandler(def); - this.documentList.actions.push(action); - }); + let documentAction = new DocumentActionModel(); + documentAction.title = 'Activiti: ' + (def.name || 'Unknown process'); + documentAction.handler = this.getBpmActionHandler(def); + this.documentList.actions.push(documentAction); - console.log(this.documentList.actions); + let folderAction = new FolderActionModel(); + folderAction.title = 'Activiti: ' + (def.name || 'Unknown process'); + folderAction.handler = this.getBpmActionHandler(def); + this.documentList.actions.push(folderAction); + }); } private getBpmActionHandler(processDefinition: any): ContentActionHandler { diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/container/container.widget.html b/ng2-components/ng2-activiti-form/src/components/widgets/container/container.widget.html index 4721683f73..ca77fdd1cd 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/container/container.widget.html +++ b/ng2-components/ng2-activiti-form/src/components/widgets/container/container.widget.html @@ -37,6 +37,12 @@
+
+ +
+
+ +
UNKNOWN WIDGET TYPE: {{field.type}}
diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/container/container.widget.ts b/ng2-components/ng2-activiti-form/src/components/widgets/container/container.widget.ts index 25dc0657df..2ee4b5da01 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/container/container.widget.ts +++ b/ng2-components/ng2-activiti-form/src/components/widgets/container/container.widget.ts @@ -19,13 +19,7 @@ import { Component, Input, AfterViewInit } from '@angular/core'; import { ContainerModel } from './../widget.model'; import { MATERIAL_DESIGN_DIRECTIVES } from 'ng2-alfresco-core'; -import { TextWidget } from './../text/text.widget'; -import { NumberWidget } from './../number/number.widget'; -import { CheckboxWidget } from './../checkbox/checkbox.widget'; -import { MultilineTextWidget } from './../multiline-text/multiline-text.widget'; -import { DropdownWidget } from './../dropdown/dropdown.widget'; -import { HyperlinkWidget } from './../hyperlink/hyperlink.widget'; -import { RadioButtonsWidget } from './../radio-buttons/radio-buttons.widget'; +import { PRIMITIVE_WIDGET_DIRECTIVES } from './../index'; declare let __moduleName: string; declare var componentHandler; @@ -37,13 +31,7 @@ declare var componentHandler; styleUrls: ['./container.widget.css'], directives: [ MATERIAL_DESIGN_DIRECTIVES, - TextWidget, - NumberWidget, - CheckboxWidget, - MultilineTextWidget, - DropdownWidget, - HyperlinkWidget, - RadioButtonsWidget + PRIMITIVE_WIDGET_DIRECTIVES ] }) export class ContainerWidget implements AfterViewInit { diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/display-text/display-text.widget.css b/ng2-components/ng2-activiti-form/src/components/widgets/display-text/display-text.widget.css new file mode 100644 index 0000000000..40e3385ccb --- /dev/null +++ b/ng2-components/ng2-activiti-form/src/components/widgets/display-text/display-text.widget.css @@ -0,0 +1 @@ +.display-text-widget {} diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/display-text/display-text.widget.html b/ng2-components/ng2-activiti-form/src/components/widgets/display-text/display-text.widget.html new file mode 100644 index 0000000000..cc784e807d --- /dev/null +++ b/ng2-components/ng2-activiti-form/src/components/widgets/display-text/display-text.widget.html @@ -0,0 +1,3 @@ +
+ {{field.value}} +
diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/display-text/display-text.widget.ts b/ng2-components/ng2-activiti-form/src/components/widgets/display-text/display-text.widget.ts new file mode 100644 index 0000000000..2f39c56db3 --- /dev/null +++ b/ng2-components/ng2-activiti-form/src/components/widgets/display-text/display-text.widget.ts @@ -0,0 +1,32 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * 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 } from '@angular/core'; +import { WidgetComponent } from './../widget.component'; + +declare let __moduleName: string; +declare var componentHandler; + +@Component({ + moduleId: __moduleName, + selector: 'display-text-widget', + templateUrl: './display-text.widget.html', + styleUrls: ['./display-text.widget.css'] +}) +export class DisplayTextWidget extends WidgetComponent { + +} diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/display-value/display-value.widget.css b/ng2-components/ng2-activiti-form/src/components/widgets/display-value/display-value.widget.css new file mode 100644 index 0000000000..c3b7a552c9 --- /dev/null +++ b/ng2-components/ng2-activiti-form/src/components/widgets/display-value/display-value.widget.css @@ -0,0 +1,3 @@ +.display-value-widget { + width: 100%; +} diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/display-value/display-value.widget.html b/ng2-components/ng2-activiti-form/src/components/widgets/display-value/display-value.widget.html new file mode 100644 index 0000000000..bb5eb65114 --- /dev/null +++ b/ng2-components/ng2-activiti-form/src/components/widgets/display-value/display-value.widget.html @@ -0,0 +1,9 @@ +
+ + +
+ diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/display-value/display-value.widget.ts b/ng2-components/ng2-activiti-form/src/components/widgets/display-value/display-value.widget.ts new file mode 100644 index 0000000000..a095b85024 --- /dev/null +++ b/ng2-components/ng2-activiti-form/src/components/widgets/display-value/display-value.widget.ts @@ -0,0 +1,32 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * 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 } from '@angular/core'; +import { WidgetComponent } from './../widget.component'; + +declare let __moduleName: string; +declare var componentHandler; + +@Component({ + moduleId: __moduleName, + selector: 'display-value-widget', + templateUrl: './display-value.widget.html', + styleUrls: ['./display-value.widget.css'] +}) +export class DisplayValueWidget extends WidgetComponent { + +} diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/index.ts b/ng2-components/ng2-activiti-form/src/components/widgets/index.ts index eff190fa36..f2c0a1e6f1 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/index.ts +++ b/ng2-components/ng2-activiti-form/src/components/widgets/index.ts @@ -15,10 +15,30 @@ * limitations under the License. */ +import { TabsWidget } from './tabs/tabs.widget'; +import { ContainerWidget } from './container/container.widget'; + +import { TextWidget } from './text/text.widget'; +import { NumberWidget } from './number/number.widget'; +import { CheckboxWidget } from './checkbox/checkbox.widget'; +import { MultilineTextWidget } from './multiline-text/multiline-text.widget'; +import { DropdownWidget } from './dropdown/dropdown.widget'; +import { HyperlinkWidget } from './hyperlink/hyperlink.widget'; +import { RadioButtonsWidget } from './radio-buttons/radio-buttons.widget'; +import { DisplayValueWidget } from './display-value/display-value.widget'; +import { DisplayTextWidget } from './display-text/display-text.widget'; + +// core +export * from './widget.component'; + +// model export * from './widget.model'; +// containers export * from './tabs/tabs.widget'; export * from './container/container.widget'; + +// primitives export * from './text/text.widget'; export * from './number/number.widget'; export * from './checkbox/checkbox.widget'; @@ -26,3 +46,24 @@ export * from './multiline-text/multiline-text.widget'; export * from './dropdown/dropdown.widget'; export * from './hyperlink/hyperlink.widget'; export * from './radio-buttons/radio-buttons.widget'; +export * from './display-value/display-value.widget'; +export * from './display-text/display-text.widget'; + +export const CONTAINER_WIDGET_DIRECTIVES: [any] = [ + TabsWidget, + ContainerWidget +]; + +export const PRIMITIVE_WIDGET_DIRECTIVES: [any] = [ + TextWidget, + NumberWidget, + CheckboxWidget, + MultilineTextWidget, + DropdownWidget, + HyperlinkWidget, + RadioButtonsWidget, + DisplayValueWidget, + DisplayTextWidget +]; + + diff --git a/ng2-components/ng2-activiti-form/src/components/widgets/widget.model.ts b/ng2-components/ng2-activiti-form/src/components/widgets/widget.model.ts index af51fe83d0..fa37006b6d 100644 --- a/ng2-components/ng2-activiti-form/src/components/widgets/widget.model.ts +++ b/ng2-components/ng2-activiti-form/src/components/widgets/widget.model.ts @@ -28,6 +28,7 @@ export class FormFieldTypes { static DROPDOWN: string = 'dropdown'; static HYPERLINK: string = 'hyperlink'; static RADIO_BUTTONS: string = 'radio-buttons'; + static DISPLAY_VALUE: string = 'readonly'; } export class FormWidgetModel { @@ -317,10 +318,12 @@ export class FormOutcomeModel extends FormWidgetModel { export class FormModel { + private UNSET_TASK_NAME: string = 'Nameless task'; + private _id: string; private _name: string; private _taskId: string; - private _taskName: string; + private _taskName: string = this.UNSET_TASK_NAME; get id(): string { return this._id; @@ -369,7 +372,7 @@ export class FormModel { this._id = json.id; this._name = json.name; this._taskId = json.taskId; - this._taskName = json.taskName; + this._taskName = json.taskName || this.UNSET_TASK_NAME; let tabCache: WidgetModelCache = {}; diff --git a/ng2-components/ng2-activiti-form/src/services/form.service.ts b/ng2-components/ng2-activiti-form/src/services/form.service.ts index 686a74743e..7942d71e3c 100644 --- a/ng2-components/ng2-activiti-form/src/services/form.service.ts +++ b/ng2-components/ng2-activiti-form/src/services/form.service.ts @@ -18,6 +18,7 @@ import { Injectable } from '@angular/core'; import { Response, Http, Headers, RequestOptions } from '@angular/http'; import { Observable } from 'rxjs/Rx'; +import { AlfrescoAuthenticationService } from 'ng2-alfresco-core'; import { FormValues } from './../components/widgets/widget.model'; import { AlfrescoSettingsService } from 'ng2-alfresco-core'; @@ -25,6 +26,7 @@ import { AlfrescoSettingsService } from 'ng2-alfresco-core'; export class FormService { constructor(private http: Http, + private authService: AlfrescoAuthenticationService, private alfrescoSettingsService: AlfrescoSettingsService) { } @@ -98,7 +100,7 @@ export class FormService { return new Headers({ 'Accept': 'application/json', 'Content-Type': 'application/json', - 'Authorization': 'Basic ' + btoa('admin' + ':' + 'admin') + 'Authorization': this.authService.getTicket('BPM') }); } diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationBPM.service.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationBPM.service.ts index 25572be09a..5c5a316fc6 100644 --- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationBPM.service.ts +++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationBPM.service.ts @@ -44,7 +44,10 @@ export class AlfrescoAuthenticationBPM extends AlfrescoAuthenticationBase implem login(username: string, password: string): Observable { return Observable.fromPromise(this.apiActivitiLogin(username, password)) .map((response: any) => { - return {type: this.TYPE, ticket: response.status}; + return { + type: this.TYPE, + ticket: 'Basic ' + btoa(`${username}:${password}`) + }; }) .catch(this.handleError); } diff --git a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationService.service.spec.ts b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationService.service.spec.ts index 26fdd818b8..deadd5ed57 100644 --- a/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationService.service.spec.ts +++ b/ng2-components/ng2-alfresco-core/src/services/AlfrescoAuthenticationService.service.spec.ts @@ -279,10 +279,14 @@ describe('AlfrescoAuthentication', () => { service = injector.get(AlfrescoAuthenticationService); spyOn(AlfrescoAuthenticationBPM.prototype, 'apiActivitiLogin').and.returnValue(fakePromiseBPM); - service.login('fake-username', 'fake-password', providers) + let username = 'fake-username'; + let password = 'fake-password'; + let token = 'Basic ' + btoa(`${username}:${password}`); + + service.login(username, password, providers) .subscribe(() => { expect(service.isLoggedIn(providers[0])).toBe(true); - expect(service.getTicket(providers[0])).toEqual('fake-post-ticket-BPM'); + expect(service.getTicket(providers[0])).toEqual(token); done(); } ); @@ -389,12 +393,16 @@ describe('AlfrescoAuthentication', () => { spyOn(AlfrescoAuthenticationECM.prototype, 'callApiLogin').and.returnValue(fakePromiseECM); spyOn(AlfrescoAuthenticationBPM.prototype, 'apiActivitiLogin').and.returnValue(fakePromiseBPM); - service.login('fake-username', 'fake-password', providers) + let username = 'fake-username'; + let password = 'fake-password'; + let bpmToken = 'Basic ' + btoa(`${username}:${password}`); + + service.login(username, password, providers) .subscribe(() => { expect(service.isLoggedIn(providers[0])).toBe(true); expect(service.isLoggedIn(providers[1])).toBe(true); expect(service.getTicket(providers[0])).toEqual('fake-post-ticket-ECM'); - expect(service.getTicket(providers[1])).toEqual('fake-post-ticket-BPM'); + expect(service.getTicket(providers[1])).toEqual(bpmToken); done(); } ); diff --git a/ng2-components/ng2-alfresco-documentlist/src/models/content-action.model.ts b/ng2-components/ng2-alfresco-documentlist/src/models/content-action.model.ts index fa568c8091..bf0a958f77 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/models/content-action.model.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/models/content-action.model.ts @@ -34,3 +34,17 @@ export class ContentActionModel { export interface ContentActionHandler { (obj: any, target?: any): any; } + +export class DocumentActionModel extends ContentActionModel { + constructor(json?: any) { + super(json); + this.target = 'document'; + } +} + +export class FolderActionModel extends ContentActionModel { + constructor(json?: any) { + super(json); + this.target = 'folder'; + } +}