= new EventEmitter();
-
@ViewChild(DataTableComponent)
dataTable: DataTableComponent;
@@ -559,15 +550,6 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
}
}
- onActionMenuError(event) {
- this.error.emit(event);
- }
-
- onActionMenuSuccess(event) {
- this.reload();
- this.success.emit(event);
- }
-
onChangePageSize(event: Pagination): void {
this.pageSize = event.maxItems;
this.reload();
@@ -583,10 +565,6 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
this.reload();
}
- onPermissionError(event) {
- this.permissionError.emit(event);
- }
-
private enforceSingleClickNavigationForMobile(): void {
if (this.isMobile()) {
this.navigationMode = DocumentListComponent.SINGLE_CLICK_NAVIGATION;
diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/document-menu-action.component.css b/ng2-components/ng2-alfresco-documentlist/src/components/document-menu-action.component.css
deleted file mode 100644
index 050cd4234b..0000000000
--- a/ng2-components/ng2-alfresco-documentlist/src/components/document-menu-action.component.css
+++ /dev/null
@@ -1,19 +0,0 @@
-.container {
- display: -webkit-box;
- display: -moz-box;
- display: -ms-flexbox;
- display: -webkit-flex;
- display: flex;
- -webkit-flex-direction: row;
- flex-direction: row;
- background-color: #fafafa;
- border-bottom: 1px solid transparent;
- border-top: 1px solid #e5e5e5;
- -webkit-box-shadow: 0 2px 4px rgba(0,0,0,.2);
- box-shadow: 0 2px 4px rgba(0,0,0,.2);
- height: 53px;
- position: relative;
- -webkit-transition: height .35s cubic-bezier(0.4,0.0,1,1),border-color .4s;
- transition: height .35s cubic-bezier(0.4,0.0,1,1),border-color .4s;
- z-index: 1;
-}
diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/document-menu-action.component.html b/ng2-components/ng2-alfresco-documentlist/src/components/document-menu-action.component.html
deleted file mode 100644
index bb2e658852..0000000000
--- a/ng2-components/ng2-alfresco-documentlist/src/components/document-menu-action.component.html
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/document-menu-action.component.spec.ts b/ng2-components/ng2-alfresco-documentlist/src/components/document-menu-action.component.spec.ts
deleted file mode 100644
index e34ca46fc8..0000000000
--- a/ng2-components/ng2-alfresco-documentlist/src/components/document-menu-action.component.spec.ts
+++ /dev/null
@@ -1,263 +0,0 @@
-/*!
- * @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 { SimpleChange } from '@angular/core';
-import { async, ComponentFixture, TestBed } from '@angular/core/testing';
-import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core';
-import { MaterialModule } from './../material.module';
-import { DocumentListService } from './../services/document-list.service';
-import { DocumentMenuActionComponent } from './document-menu-action.component';
-
-declare let jasmine: any;
-
-let exampleFolderWithCreate = {
- 'entry': {
- 'aspectNames': ['cm:auditable'],
- 'allowableOperations': ['create'],
- 'createdAt': '2017-04-03T11:34:35.708+0000',
- 'isFolder': true,
- 'isFile': false,
- 'createdByUser': { 'id': 'admin', 'displayName': 'Administrator' },
- 'modifiedAt': '2017-04-03T11:34:35.708+0000',
- 'modifiedByUser': { 'id': 'admin', 'displayName': 'Administrator' },
- 'name': 'test-folder2',
- 'id': 'c0284dc3-841d-48b2-955c-bcb2218e2b03',
- 'nodeType': 'cm:folder',
- 'parentId': '1ee81bf8-52d6-4cfc-a924-1efbc79306bf'
- }
-};
-
-let exampleFolderWithPermissions = {
- 'entry': {
- 'aspectNames': ['cm:auditable'],
- 'allowableOperations': ['check'],
- 'createdAt': '2017-04-03T11:34:35.708+0000',
- 'isFolder': true,
- 'isFile': false,
- 'createdByUser': { 'id': 'admin', 'displayName': 'Administrator' },
- 'modifiedAt': '2017-04-03T11:34:35.708+0000',
- 'modifiedByUser': { 'id': 'admin', 'displayName': 'Administrator' },
- 'name': 'test-folder2',
- 'id': 'c0284dc3-841d-48b2-955c-bcb2218e2b03',
- 'nodeType': 'cm:folder',
- 'parentId': '1ee81bf8-52d6-4cfc-a924-1efbc79306bf'
- }
-};
-
-let exampleFolderWithNoOperations = {
- 'entry': {
- 'aspectNames': ['cm:auditable'],
- 'createdAt': '2017-04-03T11:34:35.708+0000',
- 'isFolder': true,
- 'isFile': false,
- 'createdByUser': { 'id': 'admin', 'displayName': 'Administrator' },
- 'modifiedAt': '2017-04-03T11:34:35.708+0000',
- 'modifiedByUser': { 'id': 'admin', 'displayName': 'Administrator' },
- 'name': 'test-folder2',
- 'id': 'c0284dc3-841d-48b2-955c-bcb2218e2b03',
- 'nodeType': 'cm:folder',
- 'parentId': '1ee81bf8-52d6-4cfc-a924-1efbc79306bf'
- }
-};
-
-describe('Document menu action', () => {
-
- let component: DocumentMenuActionComponent;
- let fixture: ComponentFixture;
- let element: HTMLElement;
-
- beforeEach(async(() => {
- TestBed.configureTestingModule({
- imports: [
- CoreModule.forRoot(),
- MaterialModule
- ],
- declarations: [DocumentMenuActionComponent],
- providers: [
- AlfrescoTranslationService,
- DocumentListService
- ]
- });
-
- TestBed.compileComponents();
-
- let translateService = TestBed.get(AlfrescoTranslationService);
- spyOn(translateService, 'get').and.returnValue({ value: 'fake translated message' });
- }));
-
- beforeEach(() => {
- fixture = TestBed.createComponent(DocumentMenuActionComponent);
-
- element = fixture.nativeElement;
- component = fixture.componentInstance;
- fixture.detectChanges();
-
- jasmine.Ajax.install();
- });
-
- afterEach(() => {
- jasmine.Ajax.uninstall();
- });
-
- describe('Folder creation', () => {
-
- it('should createFolder fire a success event if the folder has been created', (done) => {
- component.allowableOperations = ['create'];
- component.showDialog();
-
- component.createFolder('test-folder');
-
- component.success.subscribe(() => {
- done();
- });
-
- jasmine.Ajax.requests.mostRecent().respondWith({
- status: 200,
- contentType: 'application/json',
- responseText: JSON.stringify(exampleFolderWithCreate)
- });
- });
-
- it('should createFolder fire an error event if the folder has not been created', (done) => {
- component.allowableOperations = ['create'];
- component.showDialog();
-
- component.createFolder('test-folder');
-
- component.error.subscribe(() => {
- done();
- });
-
- jasmine.Ajax.requests.mostRecent().respondWith({
- status: 403
- });
- });
-
- it('should createFolder fire an error when folder already exists', (done) => {
- component.allowableOperations = ['create'];
- component.showDialog();
-
- component.createFolder('test-folder');
-
- component.error.subscribe((err) => {
- expect(err.message).toEqual('fake translated message');
- done();
- });
-
- jasmine.Ajax.requests.mostRecent().respondWith({
- status: 403,
- responseText: JSON.stringify({ message: 'Fake folder exists', error: { statusCode: 409 } })
- });
- });
- });
-
- describe('Check Permissions', () => {
-
- it('should get the folder permission when folderId is changed', async(() => {
- let change = new SimpleChange('folder-id', 'new-folder-id', true);
- component.ngOnChanges({ 'folderId': change });
-
- jasmine.Ajax.requests.mostRecent().respondWith({
- status: 200,
- contentType: 'application/json',
- responseText: JSON.stringify(exampleFolderWithCreate)
- });
-
- fixture.whenStable().then(() => {
- fixture.detectChanges();
- let createButton: HTMLButtonElement = element.querySelector('#folder-create-button');
- expect(createButton).toBeDefined();
- expect(component.allowableOperations).toBeDefined();
- expect(component.allowableOperations).not.toBeNull();
- expect(createButton.disabled).toBeFalsy();
- });
- }));
-
- it('should disable the create button if folder does not have any allowable operations', async(() => {
- let change = new SimpleChange('folder-id', 'new-folder-id', true);
- component.ngOnChanges({ 'folderId': change });
-
- jasmine.Ajax.requests.mostRecent().respondWith({
- status: 200,
- contentType: 'application/json',
- responseText: JSON.stringify(exampleFolderWithNoOperations)
- });
- fixture.detectChanges();
- fixture.whenStable().then(() => {
- fixture.detectChanges();
- let createButton: HTMLButtonElement = element.querySelector('#folder-create-button');
- expect(createButton).toBeDefined();
- expect(createButton.disabled).toBeTruthy();
- });
- }));
-
- it('should disable the create button if folder does not have create permission', async(() => {
- let change = new SimpleChange('folder-id', 'new-folder-id', true);
- component.ngOnChanges({ 'folderId': change });
-
- jasmine.Ajax.requests.mostRecent().respondWith({
- status: 200,
- contentType: 'application/json',
- responseText: JSON.stringify(exampleFolderWithPermissions)
- });
- fixture.detectChanges();
- fixture.whenStable().then(() => {
- fixture.detectChanges();
- let createButton: HTMLButtonElement = element.querySelector('#folder-create-button');
- expect(createButton).toBeDefined();
- expect(createButton.disabled).toBeTruthy();
- });
- }));
-
- it('should not disable the option when disableWithNoPermission is false', async(() => {
- component.disableWithNoPermission = false;
- let change = new SimpleChange('folder-id', 'new-folder-id', true);
- component.ngOnChanges({ 'folderId': change });
-
- jasmine.Ajax.requests.mostRecent().respondWith({
- status: 200,
- contentType: 'application/json',
- responseText: JSON.stringify(exampleFolderWithNoOperations)
- });
-
- fixture.whenStable().then(() => {
- fixture.detectChanges();
- let createButton: HTMLButtonElement = element.querySelector('#folder-create-button');
- expect(createButton).toBeDefined();
- expect(createButton.disabled).toBeFalsy();
- });
- }));
-
- it('should emit permission event error when user does not have create permission', async(() => {
- let change = new SimpleChange('folder-id', 'new-folder-id', true);
- component.ngOnChanges({ 'folderId': change });
-
- jasmine.Ajax.requests.mostRecent().respondWith({
- status: 200,
- contentType: 'application/json',
- responseText: JSON.stringify(exampleFolderWithNoOperations)
- });
-
- component.permissionErrorEvent.subscribe((error) => {
- expect(error.type).toEqual('folder');
- expect(error.action).toEqual('create');
- });
- component.showDialog();
- component.createFolder('not-allowed');
- }));
- });
-});
diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/document-menu-action.component.ts b/ng2-components/ng2-alfresco-documentlist/src/components/document-menu-action.component.ts
deleted file mode 100644
index 5a3d8b1756..0000000000
--- a/ng2-components/ng2-alfresco-documentlist/src/components/document-menu-action.component.ts
+++ /dev/null
@@ -1,163 +0,0 @@
-/*!
- * @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, EventEmitter, Input, OnChanges, Output, SimpleChanges, ViewChild } from '@angular/core';
-import { MinimalNodeEntity } from 'alfresco-js-api';
-import { AlfrescoContentService, AlfrescoTranslationService, LogService } from 'ng2-alfresco-core';
-
-import { PermissionModel } from '../models/permissions.model';
-import { ContentActionModel } from './../models/content-action.model';
-import { DocumentListService } from './../services/document-list.service';
-
-declare let dialogPolyfill: any;
-
-const ERROR_FOLDER_ALREADY_EXIST = 409;
-
-@Component({
- selector: 'adf-document-menu-action, alfresco-document-menu-action',
- styleUrls: ['./document-menu-action.component.css'],
- templateUrl: './document-menu-action.component.html'
-})
-export class DocumentMenuActionComponent implements OnChanges {
-
- @Input()
- folderId: string;
-
- @Input()
- disableWithNoPermission: boolean = true;
-
- @Output()
- success = new EventEmitter();
-
- @Output()
- error = new EventEmitter();
-
- @Output()
- permissionErrorEvent = new EventEmitter();
-
- @ViewChild('dialog')
- dialog: any;
-
- actions: ContentActionModel[] = [];
-
- message: string;
-
- folderName: string = '';
-
- allowableOperations: string[];
-
- constructor(private documentListService: DocumentListService,
- private translateService: AlfrescoTranslationService,
- private logService: LogService,
- private contentService: AlfrescoContentService) {
- }
-
- ngOnChanges(changes: SimpleChanges) {
- if (changes && changes['folderId']) {
- if (changes['folderId'].currentValue !== changes['folderId'].previousValue) {
- this.loadCurrentNodePermissions(changes['folderId'].currentValue);
- }
- }
- }
-
- public createFolder(name: string) {
- this.cancel();
- if (this.hasCreatePermission()) {
- this.documentListService.createFolder(name, this.folderId)
- .subscribe(
- (res: MinimalNodeEntity) => {
- this.folderName = '';
- this.logService.info(res.entry);
- this.success.emit({ node: res.entry });
- },
- error => {
- if (error.response) {
- let errorMessagePlaceholder = this.getErrorMessage(error.response);
- this.message = this.formatString(errorMessagePlaceholder, [name]);
- this.error.emit({ message: this.message });
- } else {
- this.error.emit(error);
- }
- }
- );
- } else {
- this.permissionErrorEvent.emit(new PermissionModel({
- type: 'folder',
- action: 'create',
- permission: 'create'
- }));
- }
- }
-
- public showDialog() {
- if (!this.dialog.nativeElement.showModal) {
- dialogPolyfill.registerDialog(this.dialog.nativeElement);
- }
- this.dialog.nativeElement.showModal();
- }
-
- public cancel() {
- if (this.dialog) {
- this.dialog.nativeElement.close();
- }
- }
-
- /**
- * Retrive the error message using the error status code
- * @param response - object that contain the HTTP response
- * @returns {string}
- */
- private getErrorMessage(response: any): string {
- if (response.body && response.body.error.statusCode === ERROR_FOLDER_ALREADY_EXIST) {
- let errorMessage: any;
- errorMessage = this.translateService.get('FILE_UPLOAD.MESSAGES.FOLDER_ALREADY_EXIST');
- return errorMessage.value;
- }
- }
-
- /**
- * Replace a placeholder {0} in a message with the input keys
- * @param message - the message that conains the placeholder
- * @param keys - array of value
- * @returns {string} - The message without placeholder
- */
- private formatString(message: string, keys: any []) {
- let i = keys.length;
- while (i--) {
- message = message.replace(new RegExp('\\{' + i + '\\}', 'gm'), keys[i]);
- }
- return message;
- }
-
- isFolderNameEmpty() {
- return this.folderName === '' ? true : false;
- }
-
- isButtonDisabled(): boolean {
- return !this.hasCreatePermission() && this.disableWithNoPermission ? true : undefined;
- }
-
- hasCreatePermission() {
- return this.contentService.hasPermission(this, 'create');
- }
-
- loadCurrentNodePermissions(nodeId: string) {
- this.documentListService.getFolderNode(nodeId).then(node => {
- this.allowableOperations = node ? node['allowableOperations'] : null;
- }).catch(err => this.error.emit(err));
- }
-}
diff --git a/ng2-components/ng2-alfresco-documentlist/src/events/permission-error.event.ts b/ng2-components/ng2-alfresco-documentlist/src/events/permission-error.event.ts
deleted file mode 100644
index aa241c7d22..0000000000
--- a/ng2-components/ng2-alfresco-documentlist/src/events/permission-error.event.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-/*!
- * @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 { PermissionModel } from './../models/permissions.model';
-
-export class PermissionErrorEvent {
-
- readonly error: PermissionModel;
-
- constructor(error: PermissionModel) {
- this.error = error;
- }
-
-}
diff --git a/ng2-components/ng2-alfresco-search/src/components/search.component.html b/ng2-components/ng2-alfresco-search/src/components/search.component.html
index 57c2edd389..175d1db7a2 100644
--- a/ng2-components/ng2-alfresco-search/src/components/search.component.html
+++ b/ng2-components/ng2-alfresco-search/src/components/search.component.html
@@ -5,7 +5,6 @@