Skip to content

Commit 2b628f2

Browse files
authored
feat(bucket): Option to delete
* chore: version bump * build: set up github release from gren config * feat: github base api setup * feat(wip): setup add update gists service and settings * feat(wip): load remote gist * feat: added option to delete bucket
1 parent 3518e52 commit 2b628f2

17 files changed

+122
-34
lines changed

src/app/components/bucket/bucket.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<inkapp-magic-title [title]="bucketData.name" (changed)="onTitleChange($event)">
2-
#{{index}}
1+
<inkapp-magic-title [title]="bucketData.name" (changed)="onTitleChange($event)" [index]="index" (delete)="deleteBucket()">
32
</inkapp-magic-title>
43
<div class="d-flex flex-wrap">
54
<ng-container *ngFor="let color of ink|async">

src/app/components/bucket/bucket.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Observable } from 'rxjs';
55
import { filter, tap, map } from 'rxjs/operators';
66
import { AddInkColor, LoadInkColorsInBucket } from '../../store/actions/ink.action';
77
import { BucketService } from '../../services/bucket.service';
8-
import { RenameBucket } from '../../store/actions/bucket.action';
8+
import { RenameBucket, DeleteBucket } from '../../store/actions/bucket.action';
99
import { InkColorService } from '../../services/ink.service';
1010

1111
@Component({
@@ -43,4 +43,10 @@ export class BucketComponent implements OnInit {
4343
this._store.dispatch(new RenameBucket(this.bucketData._id, bucket.name));
4444
});
4545
}
46+
47+
deleteBucket() {
48+
this._bucketService.deleteBucket(this.bucketData._id).then(bucket => {
49+
this._store.dispatch(new DeleteBucket(this.bucketData._id));
50+
});
51+
}
4652
}
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
<ng-container *ngIf="!editable else editableTpl">
2-
<h5>
3-
<span>
4-
<ng-content></ng-content>
5-
</span> {{title}}</h5>
6-
</ng-container>
7-
<ng-template #editableTpl>
8-
<input type="text" class="form-control" [(ngModel)]="newTitle" (keyup.enter)="done()" (keyup.esc)="cancel()">
9-
</ng-template>
1+
<div class="inkapp--titlebar" [ngClass]="{'-has-prompt':editable}">
2+
<div class="title" (dblclick)="allowEditing()">
3+
<i class="prefix">#{{index}}</i> {{title}}
4+
</div>
5+
<div class="action">
6+
<button class="btn -is-plain -is-compact --only-on-parent-hover" (click)="delete.emit()">
7+
<i class="ink-icon icon-trash text-danger"></i>
8+
</button>
9+
</div>
10+
<div class="prompt">
11+
<input type="text" class="form-control -is-inline" [(ngModel)]="newTitle" (keyup.enter)="done()" (keyup.esc)="cancel()">
12+
</div>
13+
</div>

src/app/components/magic-title/magic-title.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { Component, OnInit, EventEmitter, Output, Input, HostListener } from '@a
77
export class MagicTitleComponent implements OnInit {
88
@Output() changed: EventEmitter<string> = new EventEmitter<string>();
99
@Input() title: string;
10+
@Input() index: number;
11+
@Output() delete: EventEmitter<string> = new EventEmitter();
1012
editable = false;
1113
newTitle: string;
1214
constructor() {}
@@ -15,8 +17,7 @@ export class MagicTitleComponent implements OnInit {
1517
this.newTitle = this.title;
1618
}
1719

18-
@HostListener('dblclick', ['$event.target'])
19-
onDblClick(e) {
20+
allowEditing(e) {
2021
this.editable = true;
2122
}
2223

src/app/services/bucket.service.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,15 @@ export class BucketService {
3535
return null;
3636
});
3737
}
38+
39+
async deleteBucket(bucketId: string) {
40+
const db = await this._db.getDatabase();
41+
return db.bucket
42+
.findOne(bucketId)
43+
.remove()
44+
.catch(error => {
45+
console.error('Error while removing bucket name');
46+
return null;
47+
});
48+
}
3849
}

src/app/store/actions/bucket.action.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ export class RenameBucket {
2020
}
2121

2222
export class ClearBuckets {
23-
static readonly type = '[Bucket] clear all';
23+
static readonly type = '[Bucket] Clear all';
2424
constructor() {}
2525
}
26+
27+
export class DeleteBucket {
28+
static readonly type = '[Bucket] Delete';
29+
constructor(public bucketId:string) {}
30+
}

src/app/store/states/bucket.state.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { State, Action, StateContext } from '@ngxs/store';
22
import { InkAppSettings, InkBucket } from '../../models';
3-
import { CreateBucket, UpdateBucket, LoadBuckets, RenameBucket, ClearBuckets } from '../actions/bucket.action';
3+
import {
4+
CreateBucket,
5+
UpdateBucket,
6+
LoadBuckets,
7+
RenameBucket,
8+
ClearBuckets,
9+
DeleteBucket
10+
} from '../actions/bucket.action';
411
import { DBService } from '../../services/db.service';
512
import { LoadInitialData } from '../actions/general.action';
613
import { UtilService } from '../../services/util.service';
@@ -46,4 +53,10 @@ export class BucketState {
4653
clearBuckets(ctx: StateContext<InkBucket>, action: ClearBuckets) {
4754
ctx.setState([]);
4855
}
56+
@Action(DeleteBucket)
57+
deleteBucket(ctx: StateContext<InkBucket>, action: DeleteBucket) {
58+
const state: any = ctx.getState();
59+
const newState = state.filter(b => b._id !== action.bucketId);
60+
ctx.setState(newState);
61+
}
4962
}

src/styles/_config.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ $ink--themes: (
1313
$ink--colors-basic: (
1414
'bg': #fff,
1515
'bg2': #f3f3f7a6,
16+
'bg3': #fefefe,
1617
'text': #aaaab1,
1718
'heading': #35335a,
1819
'border': #ededef,

src/styles/base/__index.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
@import './reset';
55
@import './typography';
66
@import './utility';
7+
@import './input';
8+
@import './buttons';

src/styles/base/_buttons.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
button.btn.-is-plain {
2+
background-color: transparent;
3+
border-color: transparent;
4+
}
5+
6+
button.btn.-is-compact {
7+
padding: 0;
8+
}

src/styles/base/_icons.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ $icons: (
3232
search: '\e91e',
3333
settings: '\e91f',
3434
sliders: '\e920',
35-
trash-2: '\e921',
35+
trash: '\e921',
3636
x: '\e922',
3737
x-square: '\e923'
3838
);

src/styles/base/_input.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
input.form-control {
2+
font-weight: 500;
3+
font-size: 1.25rem;
4+
border: 0;
5+
padding: 0.75rem 1rem;
6+
line-height: 1;
7+
background: clr('bg2');
8+
}
9+
10+
input.form-control.-is-inline {
11+
padding: 0.4rem 1rem;
12+
color: clr('heading');
13+
}

src/styles/base/_utility.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@
2828

2929
.ff-asap {
3030
}
31+
32+
.--only-on-parent-hover {
33+
display: none !important;
34+
}

src/styles/components/__index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
@import './settings-item';
77
@import './json-display';
88
@import './color-container';
9+
@import './titlebar';

src/styles/components/_color-container.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
.ink-color-container {
2+
&:hover {
3+
background-color: clr('bg3');
4+
.--only-on-parent-hover {
5+
display: inherit !important;
6+
}
7+
}
28
&.ink-view-thin {
39
border-bottom: 0;
410
margin-bottom: 0;

src/styles/components/_ink-bucket.scss

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,4 @@ inkapp-bucket {
66
border-bottom: 1px dashed transparentize(clr('primary', 'theme'), 0.82);
77
// box-shadow: 0px 8px 13px clr('shadow');
88
margin-bottom: 1rem;
9-
h5 {
10-
color: clr('heading');
11-
}
12-
13-
h5 > span {
14-
color: clr('primary', 'theme');
15-
}
16-
17-
input.form-control {
18-
color: clr('heading');
19-
font-weight: 500;
20-
font-size: 1.25rem;
21-
background: clr('bg2');
22-
border: 0;
23-
padding: 0.75rem 1rem;
24-
line-height: 1;
25-
}
269
}

src/styles/components/_titlebar.scss

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.inkapp--titlebar {
2+
display: flex;
3+
align-items: center;
4+
justify-content: space-between;
5+
6+
.title {
7+
color: clr('heading');
8+
font-size: fs('h5');
9+
font-weight: 500;
10+
.prefix {
11+
color: clr('primary', 'theme');
12+
font-style: normal;
13+
}
14+
}
15+
.action {
16+
}
17+
.prompt {
18+
display: none;
19+
flex: 1;
20+
}
21+
22+
&.-has-prompt {
23+
.title,
24+
.action {
25+
display: none;
26+
}
27+
.prompt {
28+
display: flex;
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)