mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
Merge pull request #488 from Alfresco/dev-denys-484
Form and Document List enhancements
This commit is contained in:
commit
9ee34865d8
@ -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 {
|
||||
|
@ -37,6 +37,12 @@
|
||||
<div *ngSwitchCase="'radio-buttons'">
|
||||
<radio-buttons-widget [field]="field"></radio-buttons-widget>
|
||||
</div>
|
||||
<div *ngSwitchCase="'readonly'">
|
||||
<display-value-widget [field]="field"></display-value-widget>
|
||||
</div>
|
||||
<div *ngSwitchCase="'readonly-text'">
|
||||
<display-text-widget [field]="field"></display-text-widget>
|
||||
</div>
|
||||
<div *ngSwitchDefault>
|
||||
<span>UNKNOWN WIDGET TYPE: {{field.type}}</span>
|
||||
</div>
|
||||
|
@ -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 {
|
||||
|
@ -0,0 +1 @@
|
||||
.display-text-widget {}
|
@ -0,0 +1,3 @@
|
||||
<div class="display-text-widget">
|
||||
<span>{{field.value}}</span>
|
||||
</div>
|
@ -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 {
|
||||
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
.display-value-widget {
|
||||
width: 100%;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label display-value-widget">
|
||||
<input class="mdl-textfield__input"
|
||||
type="text"
|
||||
[attr.id]="field.id"
|
||||
[(ngModel)]="field.value"
|
||||
disabled>
|
||||
<label class="mdl-textfield__label" [attr.for]="field.id">{{field.name}}</label>
|
||||
</div>
|
||||
|
@ -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 {
|
||||
|
||||
}
|
@ -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
|
||||
];
|
||||
|
||||
|
||||
|
@ -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<TabModel> = {};
|
||||
|
||||
|
@ -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')
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,10 @@ export class AlfrescoAuthenticationBPM extends AlfrescoAuthenticationBase implem
|
||||
login(username: string, password: string): Observable<any> {
|
||||
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);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
);
|
||||
|
@ -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';
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user