diff --git a/demo-shell-ng2/app/components/files/files.component.ts b/demo-shell-ng2/app/components/files/files.component.ts index 54475cad5a..81c3226751 100644 --- a/demo-shell-ng2/app/components/files/files.component.ts +++ b/demo-shell-ng2/app/components/files/files.component.ts @@ -15,7 +15,7 @@ * limitations under the License. */ import {Component} from 'angular2/core'; -import {DocumentList} from 'ng2-alfresco-documentlist/ng2-alfresco-documentlist'; +import {DocumentList, DocumentListAction} from 'ng2-alfresco-documentlist/ng2-alfresco-documentlist'; import {MDL} from 'ng2-alfresco-core/material'; @Component({ @@ -64,12 +64,14 @@ import {MDL} from 'ng2-alfresco-core/material'; [navigate]="navigation" [downloads]="downloads" (itemClick)="onItemClick($event)"> + + `, - directives: [DocumentList, MDL] + directives: [DocumentList, DocumentListAction, MDL] }) export class FilesComponent { thumbnails: boolean = true; @@ -86,4 +88,8 @@ export class FilesComponent { value: $event.value }); } + + myCustomAction1(event) { + alert('Custom action for ' + event.value.displayName); + } } diff --git a/ng2-components/ng2-alfresco-documentlist/README.md b/ng2-components/ng2-alfresco-documentlist/README.md index 5003e9cfe3..a2df8a7fef 100644 --- a/ng2-components/ng2-alfresco-documentlist/README.md +++ b/ng2-components/ng2-alfresco-documentlist/README.md @@ -1,11 +1,15 @@ # Alfresco Components for Angular 2 -Components included: +TODO: basic overview -* Document List Component -* Alfresco Service (TBD) +## Build -### Document List Component +```sh +npm install +npm run build +``` + +## Basic usage ```ts export class MyView { @@ -37,7 +41,13 @@ export class MyView { ``` -### Build +### Document actions -npm install -npm run build +```html + + + + +``` + +TODO: more details on declaring and using actions diff --git a/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.d.ts b/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.d.ts index 6b1da55294..b895c339a1 100644 --- a/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.d.ts +++ b/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.d.ts @@ -1 +1,2 @@ export * from './src/document-list.component'; +export * from './src/document-list-action.component'; diff --git a/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.js b/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.js index 9d5a620d4b..db0586b8c4 100644 --- a/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.js +++ b/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.js @@ -1,4 +1,4 @@ -System.register(['./src/document-list.component'], function(exports_1, context_1) { +System.register(['./src/document-list.component', './src/document-list-action.component'], function(exports_1, context_1) { "use strict"; var __moduleName = context_1 && context_1.id; function exportStar_1(m) { @@ -12,6 +12,9 @@ System.register(['./src/document-list.component'], function(exports_1, context_1 setters:[ function (document_list_component_1_1) { exportStar_1(document_list_component_1_1); + }, + function (document_list_action_component_1_1) { + exportStar_1(document_list_action_component_1_1); }], execute: function() { } diff --git a/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.ts b/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.ts index 6b1da55294..b895c339a1 100644 --- a/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.ts +++ b/ng2-components/ng2-alfresco-documentlist/ng2-alfresco-documentlist.ts @@ -1 +1,2 @@ export * from './src/document-list.component'; +export * from './src/document-list-action.component'; diff --git a/ng2-components/ng2-alfresco-documentlist/src/document-list-action.component.d.ts b/ng2-components/ng2-alfresco-documentlist/src/document-list-action.component.d.ts new file mode 100644 index 0000000000..066cf7a370 --- /dev/null +++ b/ng2-components/ng2-alfresco-documentlist/src/document-list-action.component.d.ts @@ -0,0 +1,29 @@ +/** + * @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 { OnInit, EventEmitter } from 'angular2/core'; +import { DocumentList } from './document-list.component'; +export declare class DocumentListAction implements OnInit { + private list; + title: string; + handler: string; + execute: EventEmitter<{}>; + private defaultHandlers; + constructor(list: DocumentList); + ngOnInit(): void; + handleStandardAction1(document: any): void; + handleStandardAction2(document: any): void; +} diff --git a/ng2-components/ng2-alfresco-documentlist/src/document-list-action.component.js b/ng2-components/ng2-alfresco-documentlist/src/document-list-action.component.js new file mode 100644 index 0000000000..2a4aa9d6d5 --- /dev/null +++ b/ng2-components/ng2-alfresco-documentlist/src/document-list-action.component.js @@ -0,0 +1,87 @@ +System.register(['angular2/core', './document-list.component', './models/document-action.model'], function(exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); + }; + var core_1, document_list_component_1, document_action_model_1; + var DocumentListAction; + return { + setters:[ + function (core_1_1) { + core_1 = core_1_1; + }, + function (document_list_component_1_1) { + document_list_component_1 = document_list_component_1_1; + }, + function (document_action_model_1_1) { + document_action_model_1 = document_action_model_1_1; + }], + execute: function() { + DocumentListAction = (function () { + function DocumentListAction(list) { + this.list = list; + this.title = 'Action'; + this.execute = new core_1.EventEmitter(); + this.defaultHandlers = {}; + // todo: just for dev/demo purposes, to be replaced with real actions + this.defaultHandlers['system1'] = this.handleStandardAction1; + this.defaultHandlers['system2'] = this.handleStandardAction2; + } + DocumentListAction.prototype.ngOnInit = function () { + var _this = this; + var model = new document_action_model_1.DocumentActionModel(); + model.title = this.title; + if (this.handler) { + var defaultHandler = this.defaultHandlers[this.handler]; + if (defaultHandler) { + model.handler = defaultHandler; + } + } + else if (this.execute) { + model.handler = function (document) { + _this.execute.emit({ + value: document + }); + }; + } + this.list.registerDocumentAction(model); + }; + DocumentListAction.prototype.handleStandardAction1 = function (document) { + window.alert('standard action 1'); + }; + DocumentListAction.prototype.handleStandardAction2 = function (document) { + window.alert('standard action 2'); + }; + __decorate([ + core_1.Input(), + __metadata('design:type', String) + ], DocumentListAction.prototype, "title", void 0); + __decorate([ + core_1.Input(), + __metadata('design:type', String) + ], DocumentListAction.prototype, "handler", void 0); + __decorate([ + core_1.Output(), + __metadata('design:type', Object) + ], DocumentListAction.prototype, "execute", void 0); + DocumentListAction = __decorate([ + core_1.Component({ + selector: 'document-action', + template: '' + }), + __metadata('design:paramtypes', [document_list_component_1.DocumentList]) + ], DocumentListAction); + return DocumentListAction; + }()); + exports_1("DocumentListAction", DocumentListAction); + } + } +}); +//# sourceMappingURL=document-list-action.component.js.map \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-documentlist/src/document-list-action.component.js.map b/ng2-components/ng2-alfresco-documentlist/src/document-list-action.component.js.map new file mode 100644 index 0000000000..ca63d8a82a --- /dev/null +++ b/ng2-components/ng2-alfresco-documentlist/src/document-list-action.component.js.map @@ -0,0 +1 @@ +{"version":3,"file":"document-list-action.component.js","sourceRoot":"","sources":["document-list-action.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;YAwBA;gBAOI,4BAAoB,IAAkB;oBAAlB,SAAI,GAAJ,IAAI,CAAc;oBAN7B,UAAK,GAAW,QAAQ,CAAC;oBAExB,YAAO,GAAG,IAAI,mBAAY,EAAE,CAAC;oBAE/B,oBAAe,GAA6C,EAAE,CAAC;oBAGnE,qEAAqE;oBACrE,IAAI,CAAC,eAAe,CAAC,SAAS,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BACf,CAAC;;sCAAA;gBAyCF,yBAAC;YAAD,CAAC,AAxCD,IAwCC;YAxCD,mDAwCC,CAAA"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-documentlist/src/document-list-action.component.ts b/ng2-components/ng2-alfresco-documentlist/src/document-list-action.component.ts new file mode 100644 index 0000000000..214d75044d --- /dev/null +++ b/ng2-components/ng2-alfresco-documentlist/src/document-list-action.component.ts @@ -0,0 +1,65 @@ +/** + * @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, OnInit, Input, Output, EventEmitter} from 'angular2/core'; +import {DocumentList} from './document-list.component'; +import {DocumentActionModel, DocumentActionHandler} from './models/document-action.model'; + +@Component({ + selector: 'document-action', + template: '' +}) +export class DocumentListAction implements OnInit { + @Input() title: string = 'Action'; + @Input() handler: string; + @Output() execute = new EventEmitter(); + + private defaultHandlers: { [id: string]: DocumentActionHandler; } = {}; + + constructor(private list: DocumentList) { + // todo: just for dev/demo purposes, to be replaced with real actions + this.defaultHandlers['system1'] = this.handleStandardAction1; + this.defaultHandlers['system2'] = this.handleStandardAction2; + } + + ngOnInit() { + let model = new DocumentActionModel(); + model.title = this.title; + + if (this.handler) { + let defaultHandler = this.defaultHandlers[this.handler]; + if (defaultHandler) { + model.handler = defaultHandler; + } + } else if (this.execute) { + model.handler = (document: any): void => { + this.execute.emit({ + value: document + }); + }; + } + + this.list.registerDocumentAction(model); + } + + handleStandardAction1(document: any) { + window.alert('standard action 1'); + } + + handleStandardAction2(document: any) { + window.alert('standard action 2'); + } +} diff --git a/ng2-components/ng2-alfresco-documentlist/src/document-list.component.d.ts b/ng2-components/ng2-alfresco-documentlist/src/document-list.component.d.ts index 3da98e87f6..8efcb7234f 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/document-list.component.d.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/document-list.component.d.ts @@ -18,6 +18,7 @@ import { OnInit, EventEmitter } from 'angular2/core'; import { AlfrescoService } from './alfresco.service'; import { FolderEntity } from './core/entities/folder.entity'; import { DocumentEntity } from './core/entities/document.entity'; +import { DocumentActionModel } from './models/document-action.model'; export declare class DocumentList implements OnInit { private _alfrescoService; navigate: boolean; @@ -34,6 +35,7 @@ export declare class DocumentList implements OnInit { folder: FolderEntity; errorMessage: any; route: any[]; + documentActions: DocumentActionModel[]; canNavigateParent(): boolean; constructor(_alfrescoService: AlfrescoService); ngOnInit(): void; @@ -42,6 +44,8 @@ export declare class DocumentList implements OnInit { goToRoute(r: any, $event: any): void; getContentUrl(document: DocumentEntity): string; getDocumentThumbnailUrl(document: DocumentEntity): string; + registerDocumentAction(action: DocumentActionModel): void; + executeDocumentAction(document: DocumentEntity, action: DocumentActionModel): void; private getItemPath(item); private displayFolderContent(path); } diff --git a/ng2-components/ng2-alfresco-documentlist/src/document-list.component.js b/ng2-components/ng2-alfresco-documentlist/src/document-list.component.js index 1622b635bc..c09f80d624 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/document-list.component.js +++ b/ng2-components/ng2-alfresco-documentlist/src/document-list.component.js @@ -36,6 +36,7 @@ System.register(['angular2/core', './alfresco.service'], function(exports_1, con }; this.currentFolderPath = 'swsdp/documentLibrary'; this.route = []; + this.documentActions = []; } DocumentList.prototype.canNavigateParent = function () { return this.navigate && @@ -94,6 +95,13 @@ System.register(['angular2/core', './alfresco.service'], function(exports_1, con DocumentList.prototype.getDocumentThumbnailUrl = function (document) { return this._alfrescoService.getDocumentThumbnailUrl(document); }; + DocumentList.prototype.registerDocumentAction = function (action) { + this.documentActions.push(action); + }; + DocumentList.prototype.executeDocumentAction = function (document, action) { + // todo: safety checks + action.handler(document); + }; DocumentList.prototype.getItemPath = function (item) { var container = item.location.container; var path = item.location.path !== '/' ? (item.location.path + '/') : '/'; @@ -137,7 +145,7 @@ System.register(['angular2/core', './alfresco.service'], function(exports_1, con styles: [ "\n :host .breadcrumb {\n margin-bottom: 4px;\n }\n\n :host .folder-icon {\n float: left;\n margin-right: 10px;\n }\n\n :host .file-icon {\n width: 52px;\n height: 52px;\n float: left;\n margin-right: 10px;\n }\n \n :host .document-header {\n font-size: 24px;\n line-height: 32px;\n }\n \n :host .document-header:hover {\n text-decoration: underline;\n }\n " ], - template: "\n
    \n
  1. \n {{r.name}}\n {{r.name}}\n
  2. \n
\n
\n \n ...\n \n \n \n
\n \n \n
\n \n \n \n \"\"\n\n

\n {{document.displayName}}\n

\n

{{document.description}}

\n \n Modified {{document.modifiedOn}} by {{document.modifiedBy}}\n \n \n
\n ", + template: "\n
    \n
  1. \n {{r.name}}\n {{r.name}}\n
  2. \n
\n
\n \n ...\n \n \n \n
\n \n \n
\n \n \n \n \"\"\n\n

\n {{document.displayName}}\n

\n

{{document.description}}

\n \n Modified {{document.modifiedOn}} by {{document.modifiedBy}}\n \n \n
\n ", providers: [alfresco_service_1.AlfrescoService] }), __metadata('design:paramtypes', [alfresco_service_1.AlfrescoService]) diff --git a/ng2-components/ng2-alfresco-documentlist/src/document-list.component.js.map b/ng2-components/ng2-alfresco-documentlist/src/document-list.component.js.map index 71dd785409..22a13987ac 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/document-list.component.js.map +++ b/ng2-components/ng2-alfresco-documentlist/src/document-list.component.js.map @@ -1 +1 @@ -{"version":3,"file":"document-list.component.js","sourceRoot":"","sources":["document-list.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;YAyGA;gBA0BI,sBACY,gBAAiC;oBAAjC,qBAAgB,GAAhB,gBAAgB,CAAiB;oBAzBpC,aAAQ,GAAY,IAAI,CAAC;oBACzB,eAAU,GAAY,KAAK,CAAC;oBACT,oBAAe,GA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AAM,EAAE;4BACJ,uoBAyBC;yBACJ;wBACD,QAAQ,EAAE,6tFAmDT;wBACD,SAAS,EAAE,CAAC,kCAAe,CAAC;qBAC/B,CAAC;;gCAAA;gBA6GF,mBAAC;YAAD,CAAC,AA5GD,IA4GC;YA5GD,uCA4GC,CAAA"} \ No newline at end of file +{"version":3,"file":"document-list.component.js","sourceRoot":"","sources":["document-list.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;YAwGA;gBA2BI,sBACY,gBAAiC;oBAAjC,qBAAgB,GAAhB,gBAAgB,CAAiB;oBA1BpC,aAAQ,GAAY,IAAI,CAAC;oBACzB,eAAU,GAAY,KAAK,CAAC;oBACT,oBAAe,GAAW,sBAAsB,CAAC;oBACpE,eAAU,GAAY,IAAI,CAAC;oBAC3B,cAAS,GAAY,IAAI,CAAC;oBAEzB,cAAS,GAAsB,IAAI,mBAAY,EAAE,CAAC;oBAE5D,eAAU,GAAG;wBACT,IAAI,EAAE,kBAAkB;wBACxB,IAAI,EAAE,uBAAuB;qBAChC,CAAC;oBACF,sBAAiB,GAAW,uBAAuB,CAAC;oBAIpD,UAAK,GAAU,EAAE,CAAC;oBAClB,oBAAe,GAA0B,EAAE,CAAC;gBAUzC,CAAC;gBARJ,wCAAiB,GAAjB;oBACI,MAAM,CAAC,IAAI,CAAC,QAAQ;wBAChB,CAAC,IAAI,CAAC,UAAU;wBAChB,IAAI,CAAC,iBAAiB,KAAK,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;gBACxD,CAAC;gBAMD,+BAAQ,GAAR;oBACI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;oBACjC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;gBACpD,CAAC;gBAED,4CAAqB,GAArB,UAAsB,MAAM;oBACxB,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;wBACT,MAAM,CAAC,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AAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,GAAG,YAAY,CAAC;gBACnD,CAAC;gBAEO,2CAAoB,GAA5B,UAA6B,IAAI;oBAAjC,iBAQC;oBAPG,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;oBAC9B,IAAI,CAAC,gBAAgB;yBAChB,SAAS,CAAC,IAAI,CAAC;yBACf,SAAS,CACN,UAAA,MAAM,IAAI,OAAA,KAAI,CAAC,MAAM,GAAG,MAAM,EAApB,CAAoB,EAC9B,UAAA,KAAK,IAAI,OAAA,KAAI,CAAC,YAAY,GAAQ,KAAK,EAA9B,CAA8B,CAC1C,CAAC;gBACV,CAAC;gBAnHD;oBAAC,YAAK,EAAE;;8DAAA;gBACR;oBAAC,YAAK,EAAE;;gEAAA;gBACR;oBAAC,YAAK,CAAC,mBAAmB,CAAC;;qEAAA;gBAC3B;oBAAC,YAAK,EAAE;;gEAAA;gBACR;oBAAC,YAAK,EAAE;;+DAAA;gBAER;oBAAC,aAAM,EAAE;;+DAAA;gBA1Fb;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,wBAAwB;wBAClC,MAAM,EAAE;4BACJ,uoBAyBC;yBACJ;wBACD,QAAQ,EAAE,2qFAiDT;wBACD,SAAS,EAAE,CAAC,kCAAe,CAAC;qBAC/B,CAAC;;gCAAA;gBAuHF,mBAAC;YAAD,CAAC,AAtHD,IAsHC;YAtHD,uCAsHC,CAAA"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-documentlist/src/document-list.component.ts b/ng2-components/ng2-alfresco-documentlist/src/document-list.component.ts index 6d192da563..4d7c0f48a6 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/document-list.component.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/document-list.component.ts @@ -18,6 +18,7 @@ import {Component, OnInit, Input, Output, EventEmitter} from 'angular2/core'; import {AlfrescoService} from './alfresco.service'; import {FolderEntity} from './core/entities/folder.entity'; import {DocumentEntity} from './core/entities/document.entity'; +import {DocumentActionModel} from './models/document-action.model'; @Component({ selector: 'alfresco-document-list', @@ -75,12 +76,10 @@ import {DocumentEntity} from './core/entities/document.entity'; Download - +
  • + {{documentAction.title}} +
  • @@ -122,6 +121,7 @@ export class DocumentList implements OnInit { errorMessage; route: any[] = []; + documentActions: DocumentActionModel[] = []; canNavigateParent(): boolean { return this.navigate && @@ -195,6 +195,15 @@ export class DocumentList implements OnInit { return this._alfrescoService.getDocumentThumbnailUrl(document); } + registerDocumentAction(action: DocumentActionModel) { + this.documentActions.push(action); + } + + executeDocumentAction(document:DocumentEntity, action: DocumentActionModel) { + // todo: safety checks + action.handler(document); + } + private getItemPath(item: DocumentEntity):string { let container = item.location.container; let path = item.location.path !== '/' ? (item.location.path + '/' ) : '/'; diff --git a/ng2-components/ng2-alfresco-documentlist/src/models/document-action.model.d.ts b/ng2-components/ng2-alfresco-documentlist/src/models/document-action.model.d.ts new file mode 100644 index 0000000000..6382fc45d0 --- /dev/null +++ b/ng2-components/ng2-alfresco-documentlist/src/models/document-action.model.d.ts @@ -0,0 +1,23 @@ +/** + * @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. + */ +export declare class DocumentActionModel { + title: string; + handler: DocumentActionHandler; +} +export interface DocumentActionHandler { + (document: any): any; +} diff --git a/ng2-components/ng2-alfresco-documentlist/src/models/document-action.model.js b/ng2-components/ng2-alfresco-documentlist/src/models/document-action.model.js new file mode 100644 index 0000000000..48a742a109 --- /dev/null +++ b/ng2-components/ng2-alfresco-documentlist/src/models/document-action.model.js @@ -0,0 +1,33 @@ +/** + * @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. + */ +System.register([], function(exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + var DocumentActionModel; + return { + setters:[], + execute: function() { + DocumentActionModel = (function () { + function DocumentActionModel() { + } + return DocumentActionModel; + }()); + exports_1("DocumentActionModel", DocumentActionModel); + } + } +}); +//# sourceMappingURL=document-action.model.js.map \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-documentlist/src/models/document-action.model.js.map b/ng2-components/ng2-alfresco-documentlist/src/models/document-action.model.js.map new file mode 100644 index 0000000000..8ba5832c03 --- /dev/null +++ b/ng2-components/ng2-alfresco-documentlist/src/models/document-action.model.js.map @@ -0,0 +1 @@ +{"version":3,"file":"document-action.model.js","sourceRoot":"","sources":["document-action.model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;YAEH;gBAAA;gBAGA,CAAC;gBAAD,0BAAC;YAAD,CAAC,AAHD,IAGC;YAHD,qDAGC,CAAA"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-documentlist/src/models/document-action.model.ts b/ng2-components/ng2-alfresco-documentlist/src/models/document-action.model.ts new file mode 100644 index 0000000000..c70f54d232 --- /dev/null +++ b/ng2-components/ng2-alfresco-documentlist/src/models/document-action.model.ts @@ -0,0 +1,25 @@ +/** + * @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. + */ + +export class DocumentActionModel { + title: string; + handler: DocumentActionHandler; +} + +export interface DocumentActionHandler { + (document: any): any; +}