[U] huddle.comp: delete story
This commit is contained in:
parent
31c03dc92c
commit
24cbd3b96c
3 changed files with 36 additions and 4 deletions
|
|
@ -18,6 +18,9 @@
|
||||||
<p class="mt-2 mb-0"><strong>{{story.user ? story.user.username : '...'}}</strong></p>
|
<p class="mt-2 mb-0"><strong>{{story.user ? story.user.username : '...'}}</strong></p>
|
||||||
<p><small>{{story.created_at | date :'dd.MM. HH:mm' }}</small></p>
|
<p><small>{{story.created_at | date :'dd.MM. HH:mm' }}</small></p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="text-center">
|
||||||
|
<small *ngIf="user.id === story.user_id" class="text-danger deleteStory" title="Delete this story." (click)="deleteStory(story)">Delete</small>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,13 @@
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.deleteStory {
|
||||||
|
cursor: pointer;
|
||||||
|
// position: absolute;
|
||||||
|
// right: 35px;
|
||||||
|
// top:20px;
|
||||||
|
}
|
||||||
|
|
||||||
.storyImage.hasStory:before {
|
.storyImage.hasStory:before {
|
||||||
content: "";
|
content: "";
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ export class HuddleComponent implements OnInit, OnDestroy {
|
||||||
selectedStory: Story;
|
selectedStory: Story;
|
||||||
stories: Story[] = [];
|
stories: Story[] = [];
|
||||||
unsubscribe: Subject<boolean> = new Subject();
|
unsubscribe: Subject<boolean> = new Subject();
|
||||||
|
user: SupabaseAuthUser;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private modalService: NgbModal,
|
private modalService: NgbModal,
|
||||||
|
|
@ -36,6 +37,9 @@ export class HuddleComponent implements OnInit, OnDestroy {
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.supaService.client.auth.user()
|
||||||
|
.then(user => this.user = user)
|
||||||
|
.catch(error => console.error(error));
|
||||||
this.route.params.subscribe(
|
this.route.params.subscribe(
|
||||||
params => {
|
params => {
|
||||||
this.reset();
|
this.reset();
|
||||||
|
|
@ -142,10 +146,11 @@ export class HuddleComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async uploadStory(src: string) {
|
uploadStory(src: string) {
|
||||||
console.log('uploadStory', event);
|
if (!this.standup || !this.user || !src) {
|
||||||
const user: SupabaseAuthUser = await this.supaService.client.auth.user();
|
return;
|
||||||
const story = new Story(user.id, this.standup.id, src);
|
}
|
||||||
|
const story = new Story(this.user.id, this.standup.id, src);
|
||||||
this.storyService.addOne(story).pipe(take(1)).subscribe(
|
this.storyService.addOne(story).pipe(take(1)).subscribe(
|
||||||
data => {
|
data => {
|
||||||
console.log('Success', data);
|
console.log('Success', data);
|
||||||
|
|
@ -155,6 +160,23 @@ export class HuddleComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deleteStory(story : Story) {
|
||||||
|
if (!story) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const confirm = window.confirm('Do you want to delete this story?')
|
||||||
|
if (confirm) {
|
||||||
|
this.storyService.deleteOne(story).pipe(take(1)).subscribe(
|
||||||
|
data => {
|
||||||
|
console.log('Success', data);
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
console.error('Failed', error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
loadStories(id: number) {
|
loadStories(id: number) {
|
||||||
return this.storyService.getStories(id).pipe(
|
return this.storyService.getStories(id).pipe(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue