mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
disable and mark accessall groups
This commit is contained in:
@@ -40,13 +40,16 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr *ngFor="let g of groups; let i = index">
|
<tr *ngFor="let g of groups; let i = index">
|
||||||
<td class="table-list-checkbox" (click)="check(g)">
|
<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>
|
||||||
<td (click)="check(g)">
|
<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>
|
||||||
<td class="text-center">
|
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ import { CollectionRequest } from 'jslib/models/request/collectionRequest';
|
|||||||
import { SelectionReadOnlyRequest } from 'jslib/models/request/selectionReadOnlyRequest';
|
import { SelectionReadOnlyRequest } from 'jslib/models/request/selectionReadOnlyRequest';
|
||||||
import { GroupResponse } from 'jslib/models/response/groupResponse';
|
import { GroupResponse } from 'jslib/models/response/groupResponse';
|
||||||
|
|
||||||
|
import { Utils } from 'jslib/misc/utils';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-collection-add-edit',
|
selector: 'app-collection-add-edit',
|
||||||
templateUrl: 'collection-add-edit.component.html',
|
templateUrl: 'collection-add-edit.component.html',
|
||||||
@@ -47,7 +49,7 @@ export class CollectionAddEditComponent implements OnInit {
|
|||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
this.editMode = this.loading = this.collectionId != null;
|
this.editMode = this.loading = this.collectionId != null;
|
||||||
const groupsResponse = await this.apiService.getGroups(this.organizationId);
|
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);
|
this.orgKey = await this.cryptoService.getOrgKey(this.organizationId);
|
||||||
|
|
||||||
if (this.editMode) {
|
if (this.editMode) {
|
||||||
@@ -58,7 +60,7 @@ export class CollectionAddEditComponent implements OnInit {
|
|||||||
this.name = await this.cryptoService.decryptToUtf8(new CipherString(collection.name), this.orgKey);
|
this.name = await this.cryptoService.decryptToUtf8(new CipherString(collection.name), this.orgKey);
|
||||||
if (collection.groups != null && this.groups != null) {
|
if (collection.groups != null && this.groups != null) {
|
||||||
collection.groups.forEach((s) => {
|
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) {
|
if (group != null && group.length > 0) {
|
||||||
(group[0] as any).checked = true;
|
(group[0] as any).checked = true;
|
||||||
(group[0] as any).readOnly = s.readOnly;
|
(group[0] as any).readOnly = s.readOnly;
|
||||||
@@ -70,10 +72,19 @@ export class CollectionAddEditComponent implements OnInit {
|
|||||||
this.title = this.i18nService.t('addCollection');
|
this.title = this.i18nService.t('addCollection');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.groups.forEach((g) => {
|
||||||
|
if (g.accessAll) {
|
||||||
|
(g as any).checked = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
check(g: GroupResponse, select?: boolean) {
|
check(g: GroupResponse, select?: boolean) {
|
||||||
|
if (g.accessAll) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
(g as any).checked = select == null ? !(g as any).checked : select;
|
(g as any).checked = select == null ? !(g as any).checked : select;
|
||||||
if (!(g as any).checked) {
|
if (!(g as any).checked) {
|
||||||
(g as any).readOnly = false;
|
(g as any).readOnly = false;
|
||||||
@@ -87,7 +98,7 @@ export class CollectionAddEditComponent implements OnInit {
|
|||||||
async submit() {
|
async submit() {
|
||||||
const request = new CollectionRequest();
|
const request = new CollectionRequest();
|
||||||
request.name = (await this.cryptoService.encrypt(this.name, this.orgKey)).encryptedString;
|
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));
|
.map((g) => new SelectionReadOnlyRequest(g.id, !!(g as any).readOnly));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user