1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-27 12:36:14 +01:00

disable and mark accessall groups

This commit is contained in:
Kyle Spearrin 2018-07-17 22:21:09 -04:00
parent 89b7672630
commit 8f95ba03ab
2 changed files with 20 additions and 6 deletions

View File

@ -40,13 +40,16 @@
<tbody>
<tr *ngFor="let g of groups; let i = index">
<td class="table-list-checkbox" (click)="check(g)">
<input type="checkbox" [(ngModel)]="g.checked" name="Groups[{{i}}].Checked">
<input type="checkbox" [(ngModel)]="g.checked" name="Groups[{{i}}].Checked" [disabled]="g.accessAll">
</td>
<td (click)="check(g)">
<span appStopProp>{{g.name}}</span>
<span appStopProp>
{{g.name}}
<i class="fa fa-th text-muted fa-fw" *ngIf="g.accessAll" title="This group can access all items"></i>
</span>
</td>
<td class="text-center">
<input type="checkbox" [(ngModel)]="g.readOnly" name="Groups[{{i}}].ReadOnly" [disabled]="!g.checked">
<input type="checkbox" [(ngModel)]="g.readOnly" name="Groups[{{i}}].ReadOnly" [disabled]="!g.checked || g.accessAll">
</td>
</tr>
</tbody>

View File

@ -20,6 +20,8 @@ import { CollectionRequest } from 'jslib/models/request/collectionRequest';
import { SelectionReadOnlyRequest } from 'jslib/models/request/selectionReadOnlyRequest';
import { GroupResponse } from 'jslib/models/response/groupResponse';
import { Utils } from 'jslib/misc/utils';
@Component({
selector: 'app-collection-add-edit',
templateUrl: 'collection-add-edit.component.html',
@ -47,7 +49,7 @@ export class CollectionAddEditComponent implements OnInit {
async ngOnInit() {
this.editMode = this.loading = this.collectionId != null;
const groupsResponse = await this.apiService.getGroups(this.organizationId);
this.groups = groupsResponse.data.map((r) => r);
this.groups = groupsResponse.data.map((r) => r).sort(Utils.getSortFunction(this.i18nService, 'name'));
this.orgKey = await this.cryptoService.getOrgKey(this.organizationId);
if (this.editMode) {
@ -58,7 +60,7 @@ export class CollectionAddEditComponent implements OnInit {
this.name = await this.cryptoService.decryptToUtf8(new CipherString(collection.name), this.orgKey);
if (collection.groups != null && this.groups != null) {
collection.groups.forEach((s) => {
const group = this.groups.filter((g) => g.id === s.id);
const group = this.groups.filter((g) => !g.accessAll && g.id === s.id);
if (group != null && group.length > 0) {
(group[0] as any).checked = true;
(group[0] as any).readOnly = s.readOnly;
@ -70,10 +72,19 @@ export class CollectionAddEditComponent implements OnInit {
this.title = this.i18nService.t('addCollection');
}
this.groups.forEach((g) => {
if (g.accessAll) {
(g as any).checked = true;
}
});
this.loading = false;
}
check(g: GroupResponse, select?: boolean) {
if (g.accessAll) {
return;
}
(g as any).checked = select == null ? !(g as any).checked : select;
if (!(g as any).checked) {
(g as any).readOnly = false;
@ -87,7 +98,7 @@ export class CollectionAddEditComponent implements OnInit {
async submit() {
const request = new CollectionRequest();
request.name = (await this.cryptoService.encrypt(this.name, this.orgKey)).encryptedString;
request.groups = this.groups.filter((g) => (g as any).checked)
request.groups = this.groups.filter((g) => (g as any).checked && !g.accessAll)
.map((g) => new SelectionReadOnlyRequest(g.id, !!(g as any).readOnly));
try {