1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-30 13:03:53 +01:00

add ownership and collection assignment from add/edit

This commit is contained in:
Kyle Spearrin 2018-10-19 12:44:52 -04:00
parent 726c323fe1
commit 5e7c9a7278
5 changed files with 60 additions and 23 deletions

2
jslib

@ -1 +1 @@
Subproject commit d1f7a97011f043a6225f603e71f0565acbe7dcdd
Subproject commit c946f01b5fbe5b84b928ae8dd4ad54a15dd1803d

View File

@ -1,11 +1,9 @@
import {
Component,
OnInit,
} from '@angular/core';
import { Component } from '@angular/core';
import { ApiService } from 'jslib/abstractions/api.service';
import { AuditService } from 'jslib/abstractions/audit.service';
import { CipherService } from 'jslib/abstractions/cipher.service';
import { CollectionService } from 'jslib/abstractions/collection.service';
import { FolderService } from 'jslib/abstractions/folder.service';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { MessagingService } from 'jslib/abstractions/messaging.service';
@ -18,6 +16,7 @@ import { UserService } from 'jslib/abstractions/user.service';
import { CipherData } from 'jslib/models/data/cipherData';
import { Cipher } from 'jslib/models/domain/cipher';
import { Organization } from 'jslib/models/domain/organization';
import { CipherCreateRequest } from 'jslib/models/request/cipherCreateRequest';
import { CipherRequest } from 'jslib/models/request/cipherRequest';
import { AddEditComponent as BaseAddEditComponent } from '../../vault/add-edit.component';
@ -26,18 +25,27 @@ import { AddEditComponent as BaseAddEditComponent } from '../../vault/add-edit.c
selector: 'app-org-vault-add-edit',
templateUrl: '../../vault/add-edit.component.html',
})
export class AddEditComponent extends BaseAddEditComponent implements OnInit {
export class AddEditComponent extends BaseAddEditComponent {
organization: Organization;
originalCipher: Cipher = null;
constructor(cipherService: CipherService, folderService: FolderService,
i18nService: I18nService, platformUtilsService: PlatformUtilsService,
auditService: AuditService, stateService: StateService,
userService: UserService, totpService: TotpService,
passwordGenerationService: PasswordGenerationService, private apiService: ApiService,
userService: UserService, collectionService: CollectionService,
totpService: TotpService, passwordGenerationService: PasswordGenerationService,
private apiService: ApiService,
messagingService: MessagingService) {
super(cipherService, folderService, i18nService, platformUtilsService, auditService, stateService,
userService, totpService, passwordGenerationService, messagingService);
userService, collectionService, totpService, passwordGenerationService, messagingService);
}
async load() {
await super.load();
if (!this.editMode) {
this.cipher.organizationId = this.organization.id;
}
await this.organizationChanged();
}
protected async loadCipher() {
@ -51,9 +59,6 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit {
}
protected encryptCipher() {
if (!this.editMode) {
this.cipher.organizationId = this.organization.id;
}
if (!this.organization.isAdmin) {
return super.encryptCipher();
}
@ -64,10 +69,11 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit {
if (!this.organization.isAdmin) {
return super.saveCipher(cipher);
}
const request = new CipherRequest(cipher);
if (this.editMode) {
const request = new CipherRequest(cipher);
return this.apiService.putCipherAdmin(this.cipherId, request);
} else {
const request = new CipherCreateRequest(cipher);
return this.apiService.postCipherAdmin(request);
}
}

View File

@ -83,7 +83,7 @@
<a href="#" appStopClick class="badge badge-primary ml-3" (click)="premiumRequired()" *ngIf="!organization && !cipher.organizationId && !canAccessPremium">
{{'premium' | i18n}}
</a>
<a href="#" appStopClick class="badge badge-primary ml-3" (click)="upgradeOrganization()" *ngIf="(organization && !organization.useTotp) || (cipher.organizationId && !cipher.organizationUseTotp)">
<a href="#" appStopClick class="badge badge-primary ml-3" (click)="upgradeOrganization()" *ngIf="(organization && !organization.useTotp) || (!organization && !canAccessPremium && cipher.organizationId && !cipher.organizationUseTotp)">
{{'upgrade' | i18n}}
</a>
</div>
@ -366,6 +366,30 @@
</select>
</div>
</div>
<ng-container *ngIf="!editMode && !organization && ownershipOptions && ownershipOptions.length > 1">
<h3 class="mt-4">{{'ownership' | i18n}}</h3>
<div class="row">
<div class="col-5">
<label for="organizationId">{{'whoOwnsThisItem' | i18n}}</label>
<select id="organizationId" class="form-control" name="OrganizationId" [(ngModel)]="cipher.organizationId"
(change)="organizationChanged()">
<option *ngFor="let o of ownershipOptions" [ngValue]="o.value">{{o.name}}</option>
</select>
</div>
</div>
</ng-container>
<ng-container *ngIf="!editMode && cipher.organizationId">
<h3 class="mt-4">{{'collections' | i18n}}</h3>
<div *ngIf="!collections || !collections.length">
{{'noCollectionsInList' | i18n}}
</div>
<ng-container *ngIf="collections && collections.length">
<div class="form-check" *ngFor="let c of collections; let i = index">
<input class="form-check-input" type="checkbox" [(ngModel)]="c.checked" id="collection-{{i}}" name="Collection[{{i}}].Checked">
<label class="form-check-label" for="collection-{{i}}">{{c.name}}</label>
</div>
</ng-container>
</ng-container>
<ng-container *ngIf="editMode">
<div class="small text-muted mt-4">
<div>

View File

@ -1,12 +1,10 @@
import {
Component,
OnInit,
} from '@angular/core';
import { Component } from '@angular/core';
import { CipherType } from 'jslib/enums/cipherType';
import { AuditService } from 'jslib/abstractions/audit.service';
import { CipherService } from 'jslib/abstractions/cipher.service';
import { CollectionService } from 'jslib/abstractions/collection.service';
import { FolderService } from 'jslib/abstractions/folder.service';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { MessagingService } from 'jslib/abstractions/messaging.service';
@ -23,7 +21,7 @@ import { LoginUriView } from 'jslib/models/view/loginUriView';
selector: 'app-vault-add-edit',
templateUrl: 'add-edit.component.html',
})
export class AddEditComponent extends BaseAddEditComponent implements OnInit {
export class AddEditComponent extends BaseAddEditComponent {
canAccessPremium: boolean;
totpCode: string;
totpCodeFormatted: string;
@ -39,13 +37,16 @@ export class AddEditComponent extends BaseAddEditComponent implements OnInit {
constructor(cipherService: CipherService, folderService: FolderService,
i18nService: I18nService, platformUtilsService: PlatformUtilsService,
auditService: AuditService, stateService: StateService,
protected userService: UserService, protected totpService: TotpService,
protected passwordGenerationService: PasswordGenerationService, protected messagingService: MessagingService) {
super(cipherService, folderService, i18nService, platformUtilsService, auditService, stateService);
userService: UserService, collectionService: CollectionService,
protected totpService: TotpService, protected passwordGenerationService: PasswordGenerationService,
protected messagingService: MessagingService) {
super(cipherService, folderService, i18nService, platformUtilsService, auditService, stateService,
userService, collectionService);
}
async ngOnInit() {
await super.load();
await super.ngOnInit();
await this.load();
this.showRevisionDate = this.cipher.passwordRevisionDisplayDate != null;
this.hasPasswordHistory = this.cipher.hasPasswordHistory;
this.cleanUp();

View File

@ -2498,5 +2498,11 @@
},
"selected": {
"message": "Selected"
},
"ownership": {
"message": "Ownership"
},
"whoOwnsThisItem": {
"message": "Who owns this item?"
}
}