mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-12-25 16:42:13 +08:00
Remove knockout-transformations dependency
This commit is contained in:
parent
8a0be3212d
commit
40dc22a317
10 changed files with 69 additions and 78 deletions
|
@ -185,7 +185,7 @@ class EmailModel {
|
|||
const parsedResult = addressparser(line);
|
||||
if (isNonEmptyArray(parsedResult)) {
|
||||
return _.compact(
|
||||
parsedResult.map((item) =>
|
||||
_.map(parsedResult, (item) =>
|
||||
item.address ? new EmailModel(item.address.replace(/^[<]+(.*)[>]+$/g, '$1'), item.name || '') : null
|
||||
)
|
||||
);
|
||||
|
|
|
@ -47,14 +47,16 @@ class ContactsAdminSettings {
|
|||
this.contactsSupported = 0 < supportedTypes.length;
|
||||
|
||||
this.contactsTypes = ko.observableArray([]);
|
||||
this.contactsTypesOptions = this.contactsTypes.map((value) => {
|
||||
const disabled = -1 === inArray(value, supportedTypes);
|
||||
return {
|
||||
'id': value,
|
||||
'name': getTypeName(value) + (disabled ? ' (' + i18n('HINTS/NOT_SUPPORTED') + ')' : ''),
|
||||
'disabled': disabled
|
||||
};
|
||||
});
|
||||
this.contactsTypesOptions = ko.computed(() =>
|
||||
_.map(this.contactsTypes(), (value) => {
|
||||
const disabled = -1 === inArray(value, supportedTypes);
|
||||
return {
|
||||
'id': value,
|
||||
'name': getTypeName(value) + (disabled ? ' (' + i18n('HINTS/NOT_SUPPORTED') + ')' : ''),
|
||||
'disabled': disabled
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
this.contactsTypes(types);
|
||||
this.contactsType = ko.observable('');
|
||||
|
|
|
@ -18,9 +18,15 @@ class PackagesAdminSettings {
|
|||
this.packagesReal = PackageStore.packagesReal;
|
||||
this.packagesMainUpdatable = PackageStore.packagesMainUpdatable;
|
||||
|
||||
this.packagesCurrent = this.packages.filter((item) => item && '' !== item.installed && !item.compare);
|
||||
this.packagesAvailableForUpdate = this.packages.filter((item) => item && '' !== item.installed && !!item.compare);
|
||||
this.packagesAvailableForInstallation = this.packages.filter((item) => item && '' === item.installed);
|
||||
this.packagesCurrent = ko.computed(() =>
|
||||
_.filter(this.packages(), (item) => item && '' !== item.installed && !item.compare)
|
||||
);
|
||||
this.packagesAvailableForUpdate = ko.computed(() =>
|
||||
_.filter(this.packages(), (item) => item && '' !== item.installed && !!item.compare)
|
||||
);
|
||||
this.packagesAvailableForInstallation = ko.computed(() =>
|
||||
_.filter(this.packages(), (item) => item && '' === item.installed)
|
||||
);
|
||||
|
||||
this.visibility = ko.computed(() => (PackageStore.packages.loading() ? 'visible' : 'hidden'));
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
class DomainAdminStore {
|
||||
constructor() {
|
||||
this.domains = ko.observableArray([]);
|
||||
this.domains.loading = ko.observable(false).extend({ 'throttle': 100 });
|
||||
this.domainsWithoutAliases = this.domains.filter((item) => item && !item.alias);
|
||||
this.domainsWithoutAliases = ko.computed(() => _.filter(this.domains(), (item) => item && !item.alias));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ class PgpUserStore {
|
|||
this.openpgpkeys = ko.observableArray([]);
|
||||
this.openpgpKeyring = null;
|
||||
|
||||
this.openpgpkeysPublic = this.openpgpkeys.filter((item) => !!(item && !item.isPrivate));
|
||||
this.openpgpkeysPrivate = this.openpgpkeys.filter((item) => !!(item && item.isPrivate));
|
||||
this.openpgpkeysPublic = ko.computed(() => _.filter(this.openpgpkeys(), (item) => !!(item && !item.isPrivate)));
|
||||
this.openpgpkeysPrivate = ko.computed(() => _.filter(this.openpgpkeys(), (item) => !!(item && item.isPrivate)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -226,9 +226,9 @@ class ComposePopupView extends AbstractViewNext {
|
|||
this.saving = ko.observable(false);
|
||||
this.attachments = ko.observableArray([]);
|
||||
|
||||
this.attachmentsInProcess = this.attachments.filter((item) => item && !item.complete());
|
||||
this.attachmentsInReady = this.attachments.filter((item) => item && item.complete());
|
||||
this.attachmentsInError = this.attachments.filter((item) => item && '' !== item.error());
|
||||
this.attachmentsInProcess = ko.computed(() => _.filter(this.attachments(), (item) => item && !item.complete()));
|
||||
this.attachmentsInReady = ko.computed(() => _.filter(this.attachments(), (item) => item && item.complete()));
|
||||
this.attachmentsInError = ko.computed(() => _.filter(this.attachments(), (item) => item && '' !== item.error()));
|
||||
|
||||
this.attachmentsCount = ko.computed(() => this.attachments().length);
|
||||
this.attachmentsInErrorCount = ko.computed(() => this.attachmentsInError().length);
|
||||
|
|
|
@ -98,27 +98,25 @@ class ContactsPopupView extends AbstractViewNext {
|
|||
|
||||
this.viewSaveTrigger = ko.observable(SaveSettingsStep.Idle);
|
||||
|
||||
this.viewPropertiesNames = this.viewProperties.filter(
|
||||
(property) => -1 < inArray(property.type(), [ContactPropertyType.FirstName, ContactPropertyType.LastName])
|
||||
this.viewPropertiesNames = ko.computed(() =>
|
||||
_.filter(
|
||||
this.viewProperties(),
|
||||
(property) => -1 < inArray(property.type(), [ContactPropertyType.FirstName, ContactPropertyType.LastName])
|
||||
)
|
||||
);
|
||||
this.viewPropertiesOther = ko.computed(() =>
|
||||
_.filter(this.viewProperties(), (property) => -1 < inArray(property.type(), [ContactPropertyType.Nick]))
|
||||
);
|
||||
|
||||
// this.viewPropertiesOther = this.viewProperties.filter(
|
||||
// (property) => -1 < inArray(property.type(), [ContactPropertyType.Note])
|
||||
// );
|
||||
this.viewPropertiesEmails = ko.computed(() =>
|
||||
_.filter(this.viewProperties(), (property) => ContactPropertyType.Email === property.type())
|
||||
);
|
||||
|
||||
this.viewPropertiesOther = ko.computed(() => {
|
||||
const list = _.filter(
|
||||
this.viewProperties(),
|
||||
(property) => -1 < inArray(property.type(), [ContactPropertyType.Nick])
|
||||
);
|
||||
return _.sortBy(list, (property) => property.type());
|
||||
});
|
||||
this.viewPropertiesWeb = ko.computed(() =>
|
||||
_.filter(this.viewProperties(), (property) => ContactPropertyType.Web === property.type())
|
||||
);
|
||||
|
||||
this.viewPropertiesEmails = this.viewProperties.filter((property) => ContactPropertyType.Email === property.type());
|
||||
|
||||
this.viewPropertiesWeb = this.viewProperties.filter((property) => ContactPropertyType.Web === property.type());
|
||||
|
||||
this.viewHasNonEmptyRequaredProperties = ko.computed(() => {
|
||||
this.viewHasNonEmptyRequiredProperties = ko.computed(() => {
|
||||
const names = this.viewPropertiesNames(),
|
||||
emails = this.viewPropertiesEmails(),
|
||||
fFilter = (property) => '' !== trim(property.value());
|
||||
|
@ -126,47 +124,37 @@ class ContactsPopupView extends AbstractViewNext {
|
|||
return !!(_.find(names, fFilter) || _.find(emails, fFilter));
|
||||
});
|
||||
|
||||
this.viewPropertiesPhones = this.viewProperties.filter((property) => ContactPropertyType.Phone === property.type());
|
||||
|
||||
this.viewPropertiesEmailsNonEmpty = this.viewPropertiesNames.filter((property) => '' !== trim(property.value()));
|
||||
|
||||
this.viewPropertiesEmailsEmptyAndOnFocused = this.viewPropertiesEmails.filter((property) => {
|
||||
const foc = property.focused();
|
||||
return '' === trim(property.value()) && !foc;
|
||||
});
|
||||
|
||||
this.viewPropertiesPhonesEmptyAndOnFocused = this.viewPropertiesPhones.filter((property) => {
|
||||
const foc = property.focused();
|
||||
return '' === trim(property.value()) && !foc;
|
||||
});
|
||||
|
||||
this.viewPropertiesWebEmptyAndOnFocused = this.viewPropertiesWeb.filter((property) => {
|
||||
const foc = property.focused();
|
||||
return '' === trim(property.value()) && !foc;
|
||||
});
|
||||
|
||||
this.viewPropertiesOtherEmptyAndOnFocused = ko.computed(() =>
|
||||
_.filter(this.viewPropertiesOther(), (property) => {
|
||||
const foc = property.focused();
|
||||
return '' === trim(property.value()) && !foc;
|
||||
})
|
||||
this.viewPropertiesPhones = ko.computed(() =>
|
||||
_.filter(this.viewProperties(), (property) => ContactPropertyType.Phone === property.type())
|
||||
);
|
||||
|
||||
this.viewPropertiesEmailsEmptyAndOnFocused.subscribe((list) => {
|
||||
fFastClearEmptyListHelper(list);
|
||||
});
|
||||
this.viewPropertiesEmailsNonEmpty = ko.computed(() =>
|
||||
_.filter(this.viewPropertiesNames(), (property) => '' !== trim(property.value()))
|
||||
);
|
||||
|
||||
this.viewPropertiesPhonesEmptyAndOnFocused.subscribe((list) => {
|
||||
fFastClearEmptyListHelper(list);
|
||||
});
|
||||
const propertyFocused = (property) => {
|
||||
const focused = property.focused();
|
||||
return '' === trim(property.value()) && !focused;
|
||||
};
|
||||
|
||||
this.viewPropertiesWebEmptyAndOnFocused.subscribe((list) => {
|
||||
fFastClearEmptyListHelper(list);
|
||||
});
|
||||
this.viewPropertiesEmailsEmptyAndOnFocused = ko.computed(() =>
|
||||
_.filter(this.viewPropertiesEmails(), propertyFocused)
|
||||
);
|
||||
|
||||
this.viewPropertiesOtherEmptyAndOnFocused.subscribe((list) => {
|
||||
fFastClearEmptyListHelper(list);
|
||||
});
|
||||
this.viewPropertiesPhonesEmptyAndOnFocused = ko.computed(() =>
|
||||
_.filter(this.viewPropertiesPhones(), propertyFocused)
|
||||
);
|
||||
|
||||
this.viewPropertiesWebEmptyAndOnFocused = ko.computed(() => _.filter(this.viewPropertiesWeb(), propertyFocused));
|
||||
|
||||
this.viewPropertiesOtherEmptyAndOnFocused = ko.computed(() =>
|
||||
_.filter(this.viewPropertiesOther(), propertyFocused)
|
||||
);
|
||||
|
||||
this.viewPropertiesEmailsEmptyAndOnFocused.subscribe(fFastClearEmptyListHelper);
|
||||
this.viewPropertiesPhonesEmptyAndOnFocused.subscribe(fFastClearEmptyListHelper);
|
||||
this.viewPropertiesWebEmptyAndOnFocused.subscribe(fFastClearEmptyListHelper);
|
||||
this.viewPropertiesOtherEmptyAndOnFocused.subscribe(fFastClearEmptyListHelper);
|
||||
|
||||
this.viewSaving = ko.observable(false);
|
||||
|
||||
|
@ -304,7 +292,7 @@ class ContactsPopupView extends AbstractViewNext {
|
|||
}
|
||||
|
||||
@command((self) => {
|
||||
const bV = self.viewHasNonEmptyRequaredProperties(),
|
||||
const bV = self.viewHasNonEmptyRequiredProperties(),
|
||||
bReadOnly = self.viewReadOnly();
|
||||
return !self.viewSaving() && bV && !bReadOnly;
|
||||
})
|
||||
|
|
|
@ -103,7 +103,6 @@
|
|||
"json3": "3.3.3",
|
||||
"knockout": "3.4.2",
|
||||
"knockout-sortable": "1.1.1",
|
||||
"knockout-transformations": "2.1.0",
|
||||
"lozad": "1.9.0",
|
||||
"matchmedia-polyfill": "0.3.2",
|
||||
"moment": "2.24.0",
|
||||
|
|
|
@ -98,7 +98,6 @@ config.paths.js = {
|
|||
'node_modules/underscore/underscore-min.js',
|
||||
'node_modules/moment/min/moment.min.js',
|
||||
'node_modules/knockout/build/output/knockout-latest.js',
|
||||
'node_modules/knockout-transformations/dist/knockout-transformations.min.js',
|
||||
'node_modules/knockout-sortable/build/knockout-sortable.min.js ',
|
||||
'node_modules/matchmedia-polyfill/matchMedia.js',
|
||||
'node_modules/matchmedia-polyfill/matchMedia.addListener.js',
|
||||
|
|
|
@ -3884,10 +3884,6 @@ knockout-sortable@1.1.1:
|
|||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/knockout-sortable/-/knockout-sortable-1.1.1.tgz#5375f02c61c30dcef4622f6e57e1bafa970d6a0e"
|
||||
|
||||
knockout-transformations@2.1.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/knockout-transformations/-/knockout-transformations-2.1.0.tgz#c9a9148dbe1649dc00518eccea704379aadb0097"
|
||||
|
||||
knockout@3.4.2:
|
||||
version "3.4.2"
|
||||
resolved "https://registry.yarnpkg.com/knockout/-/knockout-3.4.2.tgz#e87958de77ad1e936f7ce645bab8b5d7c456d937"
|
||||
|
|
Loading…
Reference in a new issue