show attachments with thumbnails and remove button

This commit is contained in:
Morgan McMillian 2018-02-19 11:14:50 -08:00
parent e3b4109d7b
commit a4b71c1707

View file

@ -351,10 +351,14 @@ export class StreamPage {
</ion-col> </ion-col>
</ion-row> </ion-row>
<ion-list> <ion-list>
<ion-item> <ion-item *ngFor="let f of files">
<ion-thumbnail item-start> <ion-thumbnail item-start>
<img src="{{ f.link }}">
</ion-thumbnail> </ion-thumbnail>
<p>filename</p> <p>{{ f.name }}</p>
<button ion-button color="dark" clear item-end (click)="unattach(f.id)">
<ion-icon name="remove-circle"></ion-icon>
</button>
</ion-item> </ion-item>
</ion-list> </ion-list>
</ion-card> </ion-card>
@ -365,6 +369,7 @@ export class NewPostModal {
title: string; title: string;
replyid: string; replyid: string;
ptext: string = ""; ptext: string = "";
files: Array<Object> = [];
fname: string = ""; fname: string = "";
fpath: string = ""; fpath: string = "";
options: Object = {}; options: Object = {};
@ -515,6 +520,11 @@ export class NewPostModal {
type: "io.pnut.core.oembed", type: "io.pnut.core.oembed",
value: oembed value: oembed
}); });
this.files.push({
name: this.fname,
link: rdata.data.link,
id: this.raw.length - 1
});
}).catch((err) => { }).catch((err) => {
console.log('-create file error-'); console.log('-create file error-');
console.log(JSON.stringify(err)); console.log(JSON.stringify(err));
@ -531,6 +541,12 @@ export class NewPostModal {
}); });
} }
unattach(id) {
console.log('removing item ' + id);
this.raw.splice(id, 1);
this.files.splice(id, 1);
}
} }
@Component({ @Component({