1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 07:43:35 +00:00

Drag n drop sorting for custom fields (#906)

* Try to fix some security vulnerabilities present in used packages

(Ran npm audit fix, solved some of the issues)

* Implement custom field ordering with new handle placement

(WIP, as an update for the jslib is needed to work correctly)

* Update reference for jslib

* Restore original state of package-lock.json

* Downgrade node sass package
This commit is contained in:
Kovah
2019-03-28 21:15:47 +01:00
committed by Kyle Spearrin
parent fd361fea59
commit bca12e8fbd
6 changed files with 443 additions and 395 deletions

15
package-lock.json generated
View File

@@ -413,6 +413,15 @@
"tslib": "^1.9.0" "tslib": "^1.9.0"
} }
}, },
"@angular/cdk": {
"version": "7.2.1",
"resolved": "https://registry.npmjs.org/@angular/cdk/-/cdk-7.2.1.tgz",
"integrity": "sha512-oU1Pjq3JkDtkXquLxWK84A2jOCeYRf352dVGbQCxWoSOQ5KBtMAd42huGidPiOSHN6/f7xZwL3n4fq3fVIut8A==",
"requires": {
"parse5": "^5.0.0",
"tslib": "^1.7.1"
}
},
"@angular/common": { "@angular/common": {
"version": "7.2.1", "version": "7.2.1",
"resolved": "https://registry.npmjs.org/@angular/common/-/common-7.2.1.tgz", "resolved": "https://registry.npmjs.org/@angular/common/-/common-7.2.1.tgz",
@@ -9648,6 +9657,12 @@
"integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=",
"dev": true "dev": true
}, },
"parse5": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.0.tgz",
"integrity": "sha512-fxNG2sQjHvlVAYmzBZS9YlDp6PTSSDwa98vkD4QgVDDCAo84z5X1t5XyJQ62ImdLXx5NdIIfihey6xpum9/gRQ==",
"optional": true
},
"parseqs": { "parseqs": {
"version": "0.0.5", "version": "0.0.5",
"resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz", "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz",

View File

@@ -21,7 +21,7 @@
"test:watch": "karma start" "test:watch": "karma start"
}, },
"devDependencies": { "devDependencies": {
"@angular/compiler-cli": "^7.2.1", "@angular/compiler-cli": "^7.2.11",
"@ngtools/webpack": "^7.2.2", "@ngtools/webpack": "^7.2.2",
"@types/chrome": "^0.0.73", "@types/chrome": "^0.0.73",
"@types/jasmine": "^2.8.8", "@types/jasmine": "^2.8.8",
@@ -75,6 +75,7 @@
}, },
"dependencies": { "dependencies": {
"@angular/animations": "7.2.1", "@angular/animations": "7.2.1",
"@angular/cdk": "7.2.1",
"@angular/common": "7.2.1", "@angular/common": "7.2.1",
"@angular/compiler": "7.2.1", "@angular/compiler": "7.2.1",
"@angular/core": "7.2.1", "@angular/core": "7.2.1",

View File

@@ -886,6 +886,9 @@
"newCustomField": { "newCustomField": {
"message": "New Custom Field" "message": "New Custom Field"
}, },
"dragToSort": {
"message": "Drag to sort"
},
"cfTypeText": { "cfTypeText": {
"message": "Text" "message": "Text"
}, },

View File

@@ -1,6 +1,7 @@
import 'core-js'; import 'core-js';
import 'zone.js/dist/zone'; import 'zone.js/dist/zone';
import { DragDropModule } from '@angular/cdk/drag-drop';
import { ToasterModule } from 'angular2-toaster'; import { ToasterModule } from 'angular2-toaster';
import { Angulartics2Module } from 'angulartics2'; import { Angulartics2Module } from 'angulartics2';
import { Angulartics2GoogleAnalytics } from 'angulartics2/ga'; import { Angulartics2GoogleAnalytics } from 'angulartics2/ga';
@@ -149,6 +150,7 @@ registerLocaleData(localeZhTw, 'zh-TW');
}), }),
ToasterModule.forRoot(), ToasterModule.forRoot(),
InfiniteScrollModule, InfiniteScrollModule,
DragDropModule,
], ],
declarations: [ declarations: [
ActionButtonsComponent, ActionButtonsComponent,

View File

@@ -1,6 +1,7 @@
@import "variables.scss"; @import "variables.scss";
.box { .box {
position: relative;
width: 100%; width: 100%;
margin: 10px 0; margin: 10px 0;
@@ -31,6 +32,112 @@
padding: 10px 15px; padding: 10px 15px;
} }
&.condensed .box-content-row, .box-content-row.condensed {
padding-top: 5px;
padding-bottom: 5px;
}
&.no-hover .box-content-row, .box-content-row.no-hover {
&:hover, &:focus {
background-color: initial !important;
}
}
}
.box-footer {
margin: 5px 10px;
font-size: $font-size-small;
@include themify($themes) {
color: themed('mutedColor');
}
}
&.list {
.box-content {
.box-content-row {
padding: 3px 10px;
text-decoration: none;
@include themify($themes) {
color: themed('textColor');
}
&.padded {
padding-top: 10px;
padding-bottom: 10px;
}
&:hover, &:focus, &.active {
@include themify($themes) {
background-color: themed('listItemBackgroundHoverColor');
}
}
&:focus {
border-left: 5px solid #000000;
padding-left: 5px;
@include themify($themes) {
border-left-color: themed('mutedColor');
}
}
.action-buttons {
.row-btn {
padding-left: 5px;
padding-right: 5px;
}
}
.text:not(.no-ellipsis), .detail {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.row-main {
display: flex;
min-width: 0;
.row-main-content {
min-width: 0;
}
}
}
&.single-line {
.box-content-row {
display: flex;
padding-top: 10px;
padding-bottom: 10px;
}
}
}
}
&.only-list {
margin-bottom: 0;
.box-content {
border-bottom: none;
}
}
&.full-list {
margin: 0;
.box-content {
border: none;
}
}
}
.stacked-boxes {
display: flex;
flex-direction: column;
}
.box-content-row { .box-content-row {
display: block; display: block;
padding: 10px 15px; padding: 10px 15px;
@@ -398,108 +505,23 @@
} }
} }
&.condensed .box-content-row, .box-content-row.condensed { .box-drag-handle {
padding-top: 5px; cursor: move;
padding-bottom: 5px; user-select: none;
} margin-left: 5px;
&.no-hover .box-content-row, .box-content-row.no-hover {
&:hover, &:focus {
background-color: initial !important;
}
}
}
.box-footer {
margin: 5px 10px;
font-size: $font-size-small;
@include themify($themes) { @include themify($themes) {
color: themed('mutedColor'); color: themed('mutedColor');
} }
} }
&.list { .cdk-drag-preview {
.box-content { position: relative;
.box-content-row { display: flex;
padding: 3px 10px; align-items: center;
text-decoration: none; opacity: .8;
@include themify($themes) { @include themify($themes) {
color: themed('textColor'); background-color: themed('boxBackgroundColor');
}
&.padded {
padding-top: 10px;
padding-bottom: 10px;
}
&:hover, &:focus, &.active {
@include themify($themes) {
background-color: themed('listItemBackgroundHoverColor');
} }
} }
&:focus {
border-left: 5px solid #000000;
padding-left: 5px;
@include themify($themes) {
border-left-color: themed('mutedColor');
}
}
.action-buttons {
.row-btn {
padding-left: 5px;
padding-right: 5px;
}
}
.text:not(.no-ellipsis), .detail {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.row-main {
display: flex;
min-width: 0;
.row-main-content {
min-width: 0;
}
}
}
&.single-line {
.box-content-row {
display: flex;
padding-top: 10px;
padding-bottom: 10px;
}
}
}
}
&.only-list {
margin-bottom: 0;
.box-content {
border-bottom: none;
}
}
&.full-list {
margin: 0;
.box-content {
border: none;
}
}
}
.stacked-boxes {
display: flex;
flex-direction: column;
}

View File

@@ -275,8 +275,9 @@
{{'customFields' | i18n}} {{'customFields' | i18n}}
</div> </div>
<div class="box-content"> <div class="box-content">
<div cdkDropList (cdkDropListDropped)="drop($event)">
<ng-container *ngIf="cipher.hasFields"> <ng-container *ngIf="cipher.hasFields">
<div class="box-content-row box-content-row-multi" appBoxRow <div class="box-content-row box-content-row-multi" appBoxRow cdkDrag
*ngFor="let f of cipher.fields; let i = index; trackBy:trackByFunction" *ngFor="let f of cipher.fields; let i = index; trackBy:trackByFunction"
[ngClass]="{'box-content-row-checkbox': f.type === fieldType.Boolean}"> [ngClass]="{'box-content-row-checkbox': f.type === fieldType.Boolean}">
<a href="#" appStopClick (click)="removeField(f)" title="{{'remove' | i18n}}"> <a href="#" appStopClick (click)="removeField(f)" title="{{'remove' | i18n}}">
@@ -302,8 +303,12 @@
[ngClass]="{'fa-eye': !f.showValue, 'fa-eye-slash': f.showValue}"></i> [ngClass]="{'fa-eye': !f.showValue, 'fa-eye-slash': f.showValue}"></i>
</a> </a>
</div> </div>
<span class="box-drag-handle" title="{{'dragToSort' | i18n}}" cdkDragHandle>
<i class="fa fa-bars"></i>
</span>
</div> </div>
</ng-container> </ng-container>
</div>
<div class="box-content-row box-content-row-newmulti" appBoxRow> <div class="box-content-row box-content-row-newmulti" appBoxRow>
<a href="#" appStopClick (click)="addField()"> <a href="#" appStopClick (click)="addField()">
<i class="fa fa-plus-circle fa-fw fa-lg"></i> {{'newCustomField' | i18n}} <i class="fa fa-plus-circle fa-fw fa-lg"></i> {{'newCustomField' | i18n}}