mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-09 09:27:03 +03:00
Added addComputables() to *Model
This commit is contained in:
parent
22f606ea75
commit
b165a1de4f
6 changed files with 221 additions and 223 deletions
|
|
@ -1,4 +1,3 @@
|
|||
import ko from 'ko';
|
||||
import { pInt } from 'Common/Utils';
|
||||
import { File } from 'Common/File';
|
||||
|
||||
|
|
@ -37,27 +36,27 @@ class ComposeAttachmentModel extends AbstractModel {
|
|||
complete: false
|
||||
});
|
||||
|
||||
this.progressText = ko.computed(() => {
|
||||
const p = this.progress();
|
||||
return 0 === p ? '' : '' + (98 < p ? 100 : p) + '%';
|
||||
});
|
||||
this.addComputables({
|
||||
progressText: () => {
|
||||
const p = this.progress();
|
||||
return 0 === p ? '' : '' + (98 < p ? 100 : p) + '%';
|
||||
},
|
||||
|
||||
this.progressStyle = ko.computed(() => {
|
||||
const p = this.progress();
|
||||
return 0 === p ? '' : 'width:' + (98 < p ? 100 : p) + '%';
|
||||
});
|
||||
progressStyle: () => {
|
||||
const p = this.progress();
|
||||
return 0 === p ? '' : 'width:' + (98 < p ? 100 : p) + '%';
|
||||
},
|
||||
|
||||
this.title = ko.computed(() => {
|
||||
return this.error() || this.fileName();
|
||||
});
|
||||
title: () => this.error() || this.fileName(),
|
||||
|
||||
this.friendlySize = ko.computed(() => {
|
||||
const localSize = this.size();
|
||||
return null === localSize ? '' : File.friendlySize(localSize);
|
||||
});
|
||||
friendlySize: () => {
|
||||
const localSize = this.size();
|
||||
return null === localSize ? '' : File.friendlySize(localSize);
|
||||
},
|
||||
|
||||
this.mimeType = ko.computed(() => File.getContentType(this.fileName()));
|
||||
this.fileExt = ko.computed(() => File.getExtension(this.fileName()));
|
||||
mimeType: () => File.getContentType(this.fileName()),
|
||||
fileExt: () => File.getExtension(this.fileName())
|
||||
});
|
||||
}
|
||||
|
||||
static fromAttachment(item)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue