From a8e209c5b5e265f769fb4e52ef7a71a0c6f9ee5f Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Fri, 17 Nov 2017 15:08:26 +0000 Subject: [PATCH] [ADF-1968] fix packaging issues i18n and assets (#2665) * fix packaging issues i18n and assets * remove other not used fodler --- demo-shell/.angular-cli.json | 51 ++-------- demo-shell/package.json | 6 +- .../src/app/components/form/form.component.ts | 10 +- .../app/services/in-memory-form.service.ts | 19 +++- lib/config/webpack.common.js | 6 +- lib/content-services/.npmignore | 22 +++-- lib/content-services/content.module.ts | 4 +- lib/core/.npmignore | 21 ++-- lib/core/core.module.ts | 4 +- lib/core/directives/node-permission.md | 97 ------------------- lib/insights/.npmignore | 21 ++-- lib/insights/insights.module.ts | 4 +- lib/process-services/.npmignore | 21 ++-- lib/process-services/process.module.ts | 4 +- 14 files changed, 99 insertions(+), 191 deletions(-) delete mode 100644 lib/core/directives/node-permission.md diff --git a/demo-shell/.angular-cli.json b/demo-shell/.angular-cli.json index 948a596ee9..f7e9ab3808 100644 --- a/demo-shell/.angular-cli.json +++ b/demo-shell/.angular-cli.json @@ -5,6 +5,7 @@ }, "apps": [ { + "name" : "dist", "root": "src", "outDir": "dist", "assets": [ @@ -25,42 +26,22 @@ { "glob": "**/*", "input": "../node_modules/@alfresco/adf-core/bundles/assets", - "output": "./core/assets/" + "output": "./assets/" }, { "glob": "**/*", "input": "../node_modules/@alfresco/adf-insights/bundles/assets", - "output": "./insights/assets/" + "output": "./assets/" }, { "glob": "**/*", "input": "../node_modules/@alfresco/adf-process-services/bundles/assets", - "output": "./process-services/assets/" + "output": "./assets/" }, { "glob": "**/*", "input": "../node_modules/@alfresco/adf-content-services/bundles/assets", - "output": "./content-services/assets/" - }, - { - "glob": "**/*", - "input": "../node_modules/@alfresco/adf-core/i18n", - "output": "./assets/@alfresco/core/i18n" - }, - { - "glob": "**/*", - "input": "../node_modules/@alfresco/adf-insights/i18n", - "output": "./assets/@alfresco/insights/i18n" - }, - { - "glob": "**/*", - "input": "../node_modules/@alfresco/adf-process-services/i18n", - "output": "./assets/@alfresco/process-services/i18n" - }, - { - "glob": "**/*", - "input": "../node_modules/@alfresco/adf-content-services/i18n", - "output": "./assets/@alfresco/content-services/i18n" + "output": "./assets/" }, { "glob": "pdf.worker.js", "input": "../node_modules/pdfjs-dist/build", "output": "./" } ], @@ -92,8 +73,8 @@ "prod": "environments/environment.prod.ts" } }, - { + "name" :"dev", "root": "src", "outDir": "dist", "assets": [ @@ -125,26 +106,6 @@ "input": "../../lib/insights/bundles/assets", "output": "./assets/" }, - { - "glob": "**/*", - "input": "../../lib/core/i18n", - "output": "./@alfresco/core/i18n" - }, - { - "glob": "**/*", - "input": "../../lib/insights/i18n", - "output": "./@alfresco/insights/i18n" - }, - { - "glob": "**/*", - "input": "../../lib/process-services/i18n", - "output": "./@alfresco/process-services/i18n" - }, - { - "glob": "**/*", - "input": "../../lib/content-services/i18n", - "output": "./@alfresco/content-services/i18n" - }, { "glob": "pdf.worker.js", "input": "../node_modules/pdfjs-dist/build", "output": "./" } ], "index": "index.html", diff --git a/demo-shell/package.json b/demo-shell/package.json index f6624027fc..37f991327e 100644 --- a/demo-shell/package.json +++ b/demo-shell/package.json @@ -5,9 +5,9 @@ "author": "Alfresco Software, Ltd.", "scripts": { "ng": "ng", - "start": "npm run server-versions && rimraf dist && ng serve --host 0.0.0.0 --app=0 --open --aot=true", - "start:dev": "npm run style:dev & npm run clean-lib-angular && npm run server-versions && rimraf dist && ng serve --host 0.0.0.0 --disable-host-check --app=1 pp-dev --proxy-config proxy.conf.js --open", - "start:dist": "npm run server-versions && rimraf dist && ng serve --host 0.0.0.0 --disable-host-check --aot=false --app=0", + "start": "npm run server-versions && rimraf dist && ng serve --host 0.0.0.0 --app dist --open --aot=true", + "start:dev": "npm run style:dev & npm run clean-lib-angular && npm run server-versions && rimraf dist && ng serve --host 0.0.0.0 --disable-host-check --app dev pp-dev --proxy-config proxy.conf.js --open", + "start:dist": "npm run server-versions && rimraf dist && ng serve --host 0.0.0.0 --disable-host-check --aot=false --app dist", "build": "npm run server-versions && rimraf dist && ng build -app=0", "build:dev": "npm run style:dev & npm run server-versions && rimraf dist && ng build -app=1", "style:dev": "npm run webpack -- --config config/webpack.style.js --progress --profile --bail --watch", diff --git a/demo-shell/src/app/components/form/form.component.ts b/demo-shell/src/app/components/form/form.component.ts index 8f7d7c0b25..97dda1e149 100644 --- a/demo-shell/src/app/components/form/form.component.ts +++ b/demo-shell/src/app/components/form/form.component.ts @@ -16,7 +16,7 @@ */ import { Component, Inject, OnInit } from '@angular/core'; -import { FormModel, FormService, LogService } from '@alfresco/adf-core'; +import { FormModel, FormService } from '@alfresco/adf-core'; import { InMemoryFormService } from '../../services/in-memory-form.service'; import { DemoForm } from './demo-form'; @@ -32,12 +32,8 @@ export class FormComponent implements OnInit { form: FormModel; - constructor(@Inject(FormService) private formService: InMemoryFormService, private logSevice: LogService) { - // Prevent default outcome actions - formService.executeOutcome.subscribe(e => { - e.preventDefault(); - this.logSevice.log(e.outcome); - }); + constructor(@Inject(FormService) private formService: InMemoryFormService) { + } ngOnInit() { diff --git a/demo-shell/src/app/services/in-memory-form.service.ts b/demo-shell/src/app/services/in-memory-form.service.ts index cf086009e8..ad80e5c51f 100644 --- a/demo-shell/src/app/services/in-memory-form.service.ts +++ b/demo-shell/src/app/services/in-memory-form.service.ts @@ -16,7 +16,7 @@ */ import { Injectable } from '@angular/core'; -import { AppConfigService, AlfrescoApiService, EcmModelService, LogService, FormFieldOption, FormService } from '@alfresco/adf-core'; +import { AppConfigService, AlfrescoApiService, EcmModelService, LogService, FormFieldOption, FormService, FormValues, FormModel, FormOutcomeModel } from '@alfresco/adf-core'; import { Observable } from 'rxjs/Observable'; interface ActivitiData { @@ -62,6 +62,23 @@ export class InMemoryFormService extends FormService { }); } + parseForm(json: any, data?: FormValues, readOnly: boolean = false): FormModel { + if (json) { + let form = new FormModel(json, data, readOnly, this); + if (!json.fields) { + form.outcomes = [ + new FormOutcomeModel(form, { + id: '$custom', + name: FormOutcomeModel.SAVE_ACTION, + isSystem: true + }) + ]; + } + return form; + } + return null; + } + /** @override */ getRestFieldValuesByProcessId(processDefinitionId: string, fieldId: string): Observable { // Uncomment this to use original call diff --git a/lib/config/webpack.common.js b/lib/config/webpack.common.js index 7f7313b4c5..a0b70e3b64 100644 --- a/lib/config/webpack.common.js +++ b/lib/config/webpack.common.js @@ -109,7 +109,9 @@ module.exports = { return resourcePath.replace('assets/', 'bundles/assets/') + url; }, publicPath: (url, resourcePath)=> { - return resourcePath + url; + var component = resourcePath.substring(0, resourcePath.indexOf('/')); + var path = resourcePath.replace(component, ''); + return path + url; } } } @@ -145,7 +147,7 @@ module.exports = { ... alfrescoLibs.map(lib => { return { from: `${lib}/i18n/`, - to: `${lib}/bundles/assets/${lib}/i18n/` + to: `${lib}/bundles/assets/adf-${lib}/i18n/` } }) ]), diff --git a/lib/content-services/.npmignore b/lib/content-services/.npmignore index a30cc5773b..4ab54fba2c 100644 --- a/lib/content-services/.npmignore +++ b/lib/content-services/.npmignore @@ -2,13 +2,6 @@ npm-debug.log .idea .npmrc -coverage/ -demo/ -dist/ -node_modules -typings/ -fonts/ - /.editorconfig /.travis.yml /*.json @@ -17,3 +10,18 @@ fonts/ /gulpfile.ts /.npmignore /.happypack + +**/*.html +**/*.js +**/*.ts +!**/*.d.ts +!**/adf-content-services.js + +coverage/ +demo/ +dist/ +node_modules +typings/ +fonts/ +i18n/ +assets/ diff --git a/lib/content-services/content.module.ts b/lib/content-services/content.module.ts index 125676c6c6..ba12ba4b14 100644 --- a/lib/content-services/content.module.ts +++ b/lib/content-services/content.module.ts @@ -62,8 +62,8 @@ import { DirectiveModule } from './directive'; provide: TRANSLATION_PROVIDER, multi: true, useValue: { - name: '@alfresco/content-services', - source: '@alfresco/content-services' + name: 'adf-content-services', + source: 'assets/adf-content-services' } } ], diff --git a/lib/core/.npmignore b/lib/core/.npmignore index a30cc5773b..210c652d91 100644 --- a/lib/core/.npmignore +++ b/lib/core/.npmignore @@ -2,13 +2,6 @@ npm-debug.log .idea .npmrc -coverage/ -demo/ -dist/ -node_modules -typings/ -fonts/ - /.editorconfig /.travis.yml /*.json @@ -17,3 +10,17 @@ fonts/ /gulpfile.ts /.npmignore /.happypack +**/*.html +**/*.js +**/*.ts +!**/*.d.ts +!**/adf-core.js + +coverage/ +demo/ +dist/ +node_modules +typings/ +fonts/ +i18n/ +assets/ diff --git a/lib/core/core.module.ts b/lib/core/core.module.ts index 2fb4dd3b7c..94a801ad08 100644 --- a/lib/core/core.module.ts +++ b/lib/core/core.module.ts @@ -85,8 +85,8 @@ export function createTranslateLoader(http: HttpClient, logService: LogService) provide: TRANSLATION_PROVIDER, multi: true, useValue: { - name: '@alfresco/core', - source: '@alfresco/core' + name: 'adf-core', + source: 'assets/adf-core' } } ], diff --git a/lib/core/directives/node-permission.md b/lib/core/directives/node-permission.md deleted file mode 100644 index ef5f8725e3..0000000000 --- a/lib/core/directives/node-permission.md +++ /dev/null @@ -1,97 +0,0 @@ -# Node Permission Directive - - - - - -- [Properties](#properties) -- [HTML element example](#html-element-example) -- [Angular component example](#angular-component-example) - * [Implementing the NodePermissionSubject interface](#implementing-the-nodepermissionsubject-interface) - * [Defining your components as an EXTENDIBLE_COMPONENT parent component](#defining-your-components-as-an-extendible_component-parent-component) - - - - - -The `NodePermissionDirective` allows you to disable an HTML element or Angular component -by taking a collection of the `MinimalNodeEntity` instances and checking the particular permission. - -The decorated element will be disabled if: - -- there are no nodes in the collection -- at least one of the nodes has no expected permission - -## Properties - -| Name | Type | Default | Description | -| --- | --- | --- | --- | -| adf-node-permission | [Permissions](https://github.com/Alfresco/alfresco-ng2-components/blob/master/ng2-components/ng2-alfresco-core/src/models/permissions.enum.ts) | null | Node permission to check (create, delete, update, updatePermissions, !create, !delete, !update, !updatePermissions)| -| adf-nodes | MinimalNodeEntity[] | [] | Nodes to check permission for | - -## HTML element example - -The best example to show `NodePermissionDirective` in action is by binding DocumentList selection property to a toolbar button. - -For example the "Delete" button should be disabled if no selection is present or if user has no rights to delete at least one node in the selection. - -```html - - - - - - ... - -``` - -The button will become disabled by default, and is going to change its state once user selects/unselects one or multiple documents that current user has permission to delete. - -## Angular component example - -You can apply the directive on any angular component which implements the NodePermissionSubject interface. The upload drag area component can be a good candidate, since this one implements that interface. Applying the directive on an angular component is pretty much the same as applying it on an html element. - -```html - - ... - -``` - -When designing a component you want to work this directive with, you have two important things to care about. - -### Implementing the NodePermissionSubject interface - -The component has to implement the NodePermissionSubject interface which basically means it has to have a boolean **disabled** property. This is the property which will be set by the directive. - -```js -import { NodePermissionSubject } from 'ng2-alfresco-core'; - -@Component({...}) -export class UploadDragAreaComponent implements NodePermissionSubject { - public disabled: boolean = false; -} -``` - -### Defining your components as an EXTENDIBLE_COMPONENT parent component - -The directive will look up the component in the dependency injection tree, up to at most one step above the current DI level (@Host). Because of this, you have to provide your component with forward referencing as the EXTENDIBLE_COMPONENT. - -```js -import { EXTENDIBLE_COMPONENT } from 'ng2-alfresco-core'; - -@Component({ - ... - providers: [ - { provide: EXTENDIBLE_COMPONENT, useExisting: forwardRef(() => UploadDragAreaComponent)} - ] -}) -export class UploadDragAreaComponent implements NodePermissionSubject { ... } -``` diff --git a/lib/insights/.npmignore b/lib/insights/.npmignore index a30cc5773b..2b22feeee3 100644 --- a/lib/insights/.npmignore +++ b/lib/insights/.npmignore @@ -2,13 +2,6 @@ npm-debug.log .idea .npmrc -coverage/ -demo/ -dist/ -node_modules -typings/ -fonts/ - /.editorconfig /.travis.yml /*.json @@ -17,3 +10,17 @@ fonts/ /gulpfile.ts /.npmignore /.happypack +**/*.html +**/*.js +**/*.ts +!**/*.d.ts +!**/adf-insights.js + +coverage/ +demo/ +dist/ +node_modules +typings/ +fonts/ +i18n/ +assets/ diff --git a/lib/insights/insights.module.ts b/lib/insights/insights.module.ts index 85ca959938..251a0085b4 100644 --- a/lib/insights/insights.module.ts +++ b/lib/insights/insights.module.ts @@ -42,8 +42,8 @@ import { DiagramsModule } from './diagram'; provide: TRANSLATION_PROVIDER, multi: true, useValue: { - name: '@alfresco/insights', - source: '@alfresco/insights' + name: 'adf-insights', + source: 'assets/adf-insights' } } ], diff --git a/lib/process-services/.npmignore b/lib/process-services/.npmignore index a30cc5773b..858e465715 100644 --- a/lib/process-services/.npmignore +++ b/lib/process-services/.npmignore @@ -2,13 +2,6 @@ npm-debug.log .idea .npmrc -coverage/ -demo/ -dist/ -node_modules -typings/ -fonts/ - /.editorconfig /.travis.yml /*.json @@ -17,3 +10,17 @@ fonts/ /gulpfile.ts /.npmignore /.happypack +**/*.html +**/*.js +**/*.ts +!**/*.d.ts +!**/adf-process-services.js + +coverage/ +demo/ +dist/ +node_modules +typings/ +fonts/ +i18n/ +assets/ diff --git a/lib/process-services/process.module.ts b/lib/process-services/process.module.ts index 4a63ce1484..70277ba9cc 100644 --- a/lib/process-services/process.module.ts +++ b/lib/process-services/process.module.ts @@ -50,8 +50,8 @@ import { PeopleModule } from './people'; provide: TRANSLATION_PROVIDER, multi: true, useValue: { - name: '@alfresco/process-services', - source: '@alfresco/process-services' + name: 'adf-process-services', + source: 'assets/adf-process-services' } } ],