[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><small>{{story.created_at | date :'dd.MM. HH:mm' }}</small></p>
|
||||
</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>
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,13 @@
|
|||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.deleteStory {
|
||||
cursor: pointer;
|
||||
// position: absolute;
|
||||
// right: 35px;
|
||||
// top:20px;
|
||||
}
|
||||
|
||||
.storyImage.hasStory:before {
|
||||
content: "";
|
||||
position: relative;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ export class HuddleComponent implements OnInit, OnDestroy {
|
|||
selectedStory: Story;
|
||||
stories: Story[] = [];
|
||||
unsubscribe: Subject<boolean> = new Subject();
|
||||
user: SupabaseAuthUser;
|
||||
|
||||
constructor(
|
||||
private modalService: NgbModal,
|
||||
|
|
@ -36,6 +37,9 @@ export class HuddleComponent implements OnInit, OnDestroy {
|
|||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.supaService.client.auth.user()
|
||||
.then(user => this.user = user)
|
||||
.catch(error => console.error(error));
|
||||
this.route.params.subscribe(
|
||||
params => {
|
||||
this.reset();
|
||||
|
|
@ -142,10 +146,11 @@ export class HuddleComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
}
|
||||
|
||||
async uploadStory(src: string) {
|
||||
console.log('uploadStory', event);
|
||||
const user: SupabaseAuthUser = await this.supaService.client.auth.user();
|
||||
const story = new Story(user.id, this.standup.id, src);
|
||||
uploadStory(src: string) {
|
||||
if (!this.standup || !this.user || !src) {
|
||||
return;
|
||||
}
|
||||
const story = new Story(this.user.id, this.standup.id, src);
|
||||
this.storyService.addOne(story).pipe(take(1)).subscribe(
|
||||
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) {
|
||||
return this.storyService.getStories(id).pipe(
|
||||
|
|
|
|||
Loading…
Reference in a new issue