Vito dde0e1807b [ADF-2912] added group everyone as constant result for add permissions (#3266)
* [ADF-2556] first step to create add people or group to permissions

* [ADF-2556] creating a dialog with user results

* [ADF-2556]
integrated service for add and remove permission from node

* [ADF-2556] fixed behaviour and style for add user group

* [ADF-2556] added some refactoring for dialog service

* [ADF-2556] refactoring the dependencies of the components

* [ADF-2556] added some fix and a new key for dialog

* [ADF-2556] start adding test for node permission service

* [ADF-2556] added test for add permission panel component

* [ADf-2556] adding tests for new add permission component

* [ADF-2556] fixed tests and added documentation

* [ADF-2556] fixed documentation for add-node components

* [ADF-2556] added peer review changes

* [ADF-2912] added group everyone as constant result for add permissions

* [ADF-2912] readded jsdoc
2018-05-11 10:44:24 +01:00

86 lines
2.8 KiB
TypeScript

/*!
* @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, ViewEncapsulation, EventEmitter, Output, ViewChild } from '@angular/core';
import { SearchPermissionConfigurationService } from './search-config-permission.service';
import { SearchService, SearchConfigurationService } from '@alfresco/adf-core';
import { SearchComponent } from '../../../search/components/search.component';
import { FormControl } from '@angular/forms';
import { debounceTime } from 'rxjs/operators';
import { MinimalNodeEntity } from 'alfresco-js-api';
@Component({
selector: 'adf-add-permission-panel',
templateUrl: './add-permission-panel.component.html',
styleUrls: ['./add-permission-panel.component.scss'],
encapsulation: ViewEncapsulation.None,
providers: [
{ provide: SearchConfigurationService, useClass: SearchPermissionConfigurationService },
SearchService
]
})
export class AddPermissionPanelComponent {
@ViewChild('search')
search: SearchComponent;
/** Emitted when a permission list item is selected. */
@Output()
select: EventEmitter<any> = new EventEmitter();
searchInput: FormControl = new FormControl();
searchedWord = '';
debounceSearch: number = 200;
selectedItems: MinimalNodeEntity[] = [];
EVERYONE: MinimalNodeEntity = { entry: { properties: {'cm:authorityName': 'GROUP_EVERYONE'}}};
constructor() {
this.searchInput.valueChanges
.pipe(
debounceTime(this.debounceSearch)
)
.subscribe((searchValue) => {
this.searchedWord = searchValue;
if (!searchValue) {
this.search.resetResults();
}
});
}
elementClicked(item: MinimalNodeEntity) {
if (this.isAlreadySelected(item)) {
this.selectedItems.splice(this.selectedItems.indexOf(item), 1);
} else {
this.selectedItems.push(item);
}
this.select.emit(this.selectedItems);
}
private isAlreadySelected(item: MinimalNodeEntity): boolean {
return this.selectedItems.indexOf(item) >= 0;
}
clearSearch() {
this.searchedWord = '';
this.selectedItems.splice(0, this.selectedItems.length);
this.search.resetResults();
}
}