mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-03 22:47:03 +03:00
prettier --write
This commit is contained in:
parent
450528ff00
commit
8a0be3212d
164 changed files with 7053 additions and 9008 deletions
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
import window from 'window';
|
||||
import _ from '_';
|
||||
import $ from '$';
|
||||
|
|
@ -7,22 +6,34 @@ import key from 'key';
|
|||
import Jua from 'Jua';
|
||||
|
||||
import {
|
||||
SaveSettingsStep, ContactPropertyType, ComposeType,
|
||||
Capa, Magics, StorageResultType, Notification, KeyState
|
||||
SaveSettingsStep,
|
||||
ContactPropertyType,
|
||||
ComposeType,
|
||||
Capa,
|
||||
Magics,
|
||||
StorageResultType,
|
||||
Notification,
|
||||
KeyState
|
||||
} from 'Common/Enums';
|
||||
|
||||
import {
|
||||
delegateRunOnDestroy, computedPagenatorHelper,
|
||||
inArray, trim, windowResizeCallback,
|
||||
isNonEmptyArray, fakeMd5, pInt, isUnd
|
||||
delegateRunOnDestroy,
|
||||
computedPagenatorHelper,
|
||||
inArray,
|
||||
trim,
|
||||
windowResizeCallback,
|
||||
isNonEmptyArray,
|
||||
fakeMd5,
|
||||
pInt,
|
||||
isUnd
|
||||
} from 'Common/Utils';
|
||||
|
||||
import {CONTACTS_PER_PAGE} from 'Common/Consts';
|
||||
import {bMobileDevice} from 'Common/Globals';
|
||||
import { CONTACTS_PER_PAGE } from 'Common/Consts';
|
||||
import { bMobileDevice } from 'Common/Globals';
|
||||
|
||||
import {Selector} from 'Common/Selector';
|
||||
import {exportContactsVcf, exportContactsCsv, uploadContacts} from 'Common/Links';
|
||||
import {i18n, getNotification} from 'Common/Translator';
|
||||
import { Selector } from 'Common/Selector';
|
||||
import { exportContactsVcf, exportContactsCsv, uploadContacts } from 'Common/Links';
|
||||
import { i18n, getNotification } from 'Common/Translator';
|
||||
|
||||
import SettingsStore from 'Stores/User/Settings';
|
||||
import ContactStore from 'Stores/User/Contact';
|
||||
|
|
@ -31,31 +42,29 @@ import Remote from 'Remote/User/Ajax';
|
|||
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
import {EmailModel} from 'Model/Email';
|
||||
import {ContactModel} from 'Model/Contact';
|
||||
import {ContactPropertyModel} from 'Model/ContactProperty';
|
||||
import { EmailModel } from 'Model/Email';
|
||||
import { ContactModel } from 'Model/Contact';
|
||||
import { ContactPropertyModel } from 'Model/ContactProperty';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
import { getApp } from 'Helper/Apps/User';
|
||||
|
||||
import {popup, command, showScreenPopup, hideScreenPopup, routeOn, routeOff} from 'Knoin/Knoin';
|
||||
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
||||
import { popup, command, showScreenPopup, hideScreenPopup, routeOn, routeOff } from 'Knoin/Knoin';
|
||||
import { AbstractViewNext } from 'Knoin/AbstractViewNext';
|
||||
|
||||
@popup({
|
||||
name: 'View/Popup/Contacts',
|
||||
templateID: 'PopupsContacts'
|
||||
})
|
||||
class ContactsPopupView extends AbstractViewNext
|
||||
{
|
||||
class ContactsPopupView extends AbstractViewNext {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
const
|
||||
fFastClearEmptyListHelper = (list) => {
|
||||
if (list && 0 < list.length) {
|
||||
this.viewProperties.removeAll(list);
|
||||
delegateRunOnDestroy(list);
|
||||
}
|
||||
};
|
||||
const fFastClearEmptyListHelper = (list) => {
|
||||
if (list && 0 < list.length) {
|
||||
this.viewProperties.removeAll(list);
|
||||
delegateRunOnDestroy(list);
|
||||
}
|
||||
};
|
||||
|
||||
this.bBackToCompose = false;
|
||||
this.sLastComposeFocusedField = '';
|
||||
|
|
@ -98,36 +107,28 @@ class ContactsPopupView extends AbstractViewNext
|
|||
// );
|
||||
|
||||
this.viewPropertiesOther = ko.computed(() => {
|
||||
const list = _.filter(this.viewProperties(),
|
||||
const list = _.filter(
|
||||
this.viewProperties(),
|
||||
(property) => -1 < inArray(property.type(), [ContactPropertyType.Nick])
|
||||
);
|
||||
return _.sortBy(list, (property) => property.type());
|
||||
});
|
||||
|
||||
this.viewPropertiesEmails = this.viewProperties.filter(
|
||||
(property) => ContactPropertyType.Email === property.type()
|
||||
);
|
||||
this.viewPropertiesEmails = this.viewProperties.filter((property) => ContactPropertyType.Email === property.type());
|
||||
|
||||
this.viewPropertiesWeb = this.viewProperties.filter(
|
||||
(property) => ContactPropertyType.Web === property.type()
|
||||
);
|
||||
this.viewPropertiesWeb = this.viewProperties.filter((property) => ContactPropertyType.Web === property.type());
|
||||
|
||||
this.viewHasNonEmptyRequaredProperties = ko.computed(() => {
|
||||
const
|
||||
names = this.viewPropertiesNames(),
|
||||
const names = this.viewPropertiesNames(),
|
||||
emails = this.viewPropertiesEmails(),
|
||||
fFilter = (property) => '' !== trim(property.value());
|
||||
|
||||
return !!(_.find(names, fFilter) || _.find(emails, fFilter));
|
||||
});
|
||||
|
||||
this.viewPropertiesPhones = this.viewProperties.filter(
|
||||
(property) => ContactPropertyType.Phone === property.type()
|
||||
);
|
||||
this.viewPropertiesPhones = this.viewProperties.filter((property) => ContactPropertyType.Phone === property.type());
|
||||
|
||||
this.viewPropertiesEmailsNonEmpty = this.viewPropertiesNames.filter(
|
||||
(property) => '' !== trim(property.value())
|
||||
);
|
||||
this.viewPropertiesEmailsNonEmpty = this.viewPropertiesNames.filter((property) => '' !== trim(property.value()));
|
||||
|
||||
this.viewPropertiesEmailsEmptyAndOnFocused = this.viewPropertiesEmails.filter((property) => {
|
||||
const foc = property.focused();
|
||||
|
|
@ -144,8 +145,8 @@ class ContactsPopupView extends AbstractViewNext
|
|||
return '' === trim(property.value()) && !foc;
|
||||
});
|
||||
|
||||
this.viewPropertiesOtherEmptyAndOnFocused = ko.computed(
|
||||
() => _.filter(this.viewPropertiesOther(), (property) => {
|
||||
this.viewPropertiesOtherEmptyAndOnFocused = ko.computed(() =>
|
||||
_.filter(this.viewPropertiesOther(), (property) => {
|
||||
const foc = property.focused();
|
||||
return '' === trim(property.value()) && !foc;
|
||||
})
|
||||
|
|
@ -178,31 +179,32 @@ class ContactsPopupView extends AbstractViewNext
|
|||
this.contacts.subscribe(windowResizeCallback);
|
||||
this.viewProperties.subscribe(windowResizeCallback);
|
||||
|
||||
this.contactsChecked = ko.computed(
|
||||
() => _.filter(this.contacts(), (item) => item.checked())
|
||||
);
|
||||
this.contactsChecked = ko.computed(() => _.filter(this.contacts(), (item) => item.checked()));
|
||||
|
||||
this.contactsCheckedOrSelected = ko.computed(() => {
|
||||
const
|
||||
checked = this.contactsChecked(),
|
||||
const checked = this.contactsChecked(),
|
||||
selected = this.currentContact();
|
||||
|
||||
return _.union(checked, selected ? [selected] : []);
|
||||
});
|
||||
|
||||
this.contactsCheckedOrSelectedUids = ko.computed(
|
||||
() => _.map(this.contactsCheckedOrSelected(), (contact) => contact.idContact)
|
||||
this.contactsCheckedOrSelectedUids = ko.computed(() =>
|
||||
_.map(this.contactsCheckedOrSelected(), (contact) => contact.idContact)
|
||||
);
|
||||
|
||||
this.selector = new Selector(
|
||||
this.contacts, this.currentContact, null,
|
||||
'.e-contact-item .actionHandle', '.e-contact-item.selected',
|
||||
'.e-contact-item .checkboxItem', '.e-contact-item.focused');
|
||||
this.contacts,
|
||||
this.currentContact,
|
||||
null,
|
||||
'.e-contact-item .actionHandle',
|
||||
'.e-contact-item.selected',
|
||||
'.e-contact-item .checkboxItem',
|
||||
'.e-contact-item.focused'
|
||||
);
|
||||
|
||||
this.selector.on('onItemSelect', (contact) => {
|
||||
this.populateViewContact(contact ? contact : null);
|
||||
if (!contact)
|
||||
{
|
||||
if (!contact) {
|
||||
this.emptySelection(true);
|
||||
}
|
||||
});
|
||||
|
|
@ -219,8 +221,7 @@ class ContactsPopupView extends AbstractViewNext
|
|||
// this.saveCommandDebounce = _.debounce(_.bind(this.saveCommand, this), 1000);
|
||||
|
||||
this.viewHash.subscribe(() => {
|
||||
if (this.watchHash() && !this.viewReadOnly() && !this.watchDirty())
|
||||
{
|
||||
if (this.watchHash() && !this.viewReadOnly() && !this.watchDirty()) {
|
||||
this.watchDirty(true);
|
||||
}
|
||||
});
|
||||
|
|
@ -242,30 +243,23 @@ class ContactsPopupView extends AbstractViewNext
|
|||
|
||||
@command((self) => 0 < self.contactsCheckedOrSelected().length)
|
||||
newMessageCommand() {
|
||||
|
||||
if (!Settings.capa(Capa.Composer))
|
||||
{
|
||||
if (!Settings.capa(Capa.Composer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let
|
||||
aE = [],
|
||||
let aE = [],
|
||||
toEmails = null,
|
||||
ccEmails = null,
|
||||
bccEmails = null;
|
||||
|
||||
const aC = this.contactsCheckedOrSelected();
|
||||
if (isNonEmptyArray(aC))
|
||||
{
|
||||
if (isNonEmptyArray(aC)) {
|
||||
aE = _.map(aC, (oItem) => {
|
||||
if (oItem)
|
||||
{
|
||||
const
|
||||
data = oItem.getNameAndEmailHelper(),
|
||||
if (oItem) {
|
||||
const data = oItem.getNameAndEmailHelper(),
|
||||
email = data ? new EmailModel(data[0], data[1]) : null;
|
||||
|
||||
if (email && email.validate())
|
||||
{
|
||||
if (email && email.validate()) {
|
||||
return email;
|
||||
}
|
||||
}
|
||||
|
|
@ -276,14 +270,12 @@ class ContactsPopupView extends AbstractViewNext
|
|||
aE = _.compact(aE);
|
||||
}
|
||||
|
||||
if (isNonEmptyArray(aE))
|
||||
{
|
||||
if (isNonEmptyArray(aE)) {
|
||||
this.bBackToCompose = false;
|
||||
|
||||
hideScreenPopup(ContactsPopupView);
|
||||
|
||||
switch (this.sLastComposeFocusedField)
|
||||
{
|
||||
switch (this.sLastComposeFocusedField) {
|
||||
case 'cc':
|
||||
ccEmails = aE;
|
||||
break;
|
||||
|
|
@ -312,67 +304,66 @@ class ContactsPopupView extends AbstractViewNext
|
|||
}
|
||||
|
||||
@command((self) => {
|
||||
const
|
||||
bV = self.viewHasNonEmptyRequaredProperties(),
|
||||
const bV = self.viewHasNonEmptyRequaredProperties(),
|
||||
bReadOnly = self.viewReadOnly();
|
||||
return !self.viewSaving() && bV && !bReadOnly;
|
||||
})
|
||||
saveCommand() {
|
||||
|
||||
this.viewSaving(true);
|
||||
this.viewSaveTrigger(SaveSettingsStep.Animate);
|
||||
|
||||
const
|
||||
requestUid = fakeMd5(),
|
||||
const requestUid = fakeMd5(),
|
||||
properties = [];
|
||||
|
||||
_.each(this.viewProperties(), (oItem) => {
|
||||
if (oItem.type() && oItem.type() !== ContactPropertyType.FullName && '' !== trim(oItem.value()))
|
||||
{
|
||||
if (oItem.type() && oItem.type() !== ContactPropertyType.FullName && '' !== trim(oItem.value())) {
|
||||
properties.push([oItem.type(), oItem.value(), oItem.typeStr()]);
|
||||
}
|
||||
});
|
||||
|
||||
Remote.contactSave((sResult, oData) => {
|
||||
Remote.contactSave(
|
||||
(sResult, oData) => {
|
||||
let res = false;
|
||||
this.viewSaving(false);
|
||||
|
||||
let res = false;
|
||||
this.viewSaving(false);
|
||||
if (
|
||||
StorageResultType.Success === sResult &&
|
||||
oData &&
|
||||
oData.Result &&
|
||||
oData.Result.RequestUid === requestUid &&
|
||||
0 < pInt(oData.Result.ResultID)
|
||||
) {
|
||||
if ('' === this.viewID()) {
|
||||
this.viewID(pInt(oData.Result.ResultID));
|
||||
}
|
||||
|
||||
if (StorageResultType.Success === sResult && oData && oData.Result &&
|
||||
oData.Result.RequestUid === requestUid && 0 < pInt(oData.Result.ResultID))
|
||||
{
|
||||
if ('' === this.viewID())
|
||||
{
|
||||
this.viewID(pInt(oData.Result.ResultID));
|
||||
this.reloadContactList();
|
||||
res = true;
|
||||
}
|
||||
|
||||
this.reloadContactList();
|
||||
res = true;
|
||||
}
|
||||
|
||||
_.delay(() => {
|
||||
this.viewSaveTrigger(res ? SaveSettingsStep.TrueResult : SaveSettingsStep.FalseResult);
|
||||
}, Magics.Time350ms);
|
||||
|
||||
if (res)
|
||||
{
|
||||
this.watchDirty(false);
|
||||
|
||||
_.delay(() => {
|
||||
this.viewSaveTrigger(SaveSettingsStep.Idle);
|
||||
}, Magics.Time1s);
|
||||
}
|
||||
this.viewSaveTrigger(res ? SaveSettingsStep.TrueResult : SaveSettingsStep.FalseResult);
|
||||
}, Magics.Time350ms);
|
||||
|
||||
}, requestUid, this.viewID(), properties);
|
||||
if (res) {
|
||||
this.watchDirty(false);
|
||||
|
||||
_.delay(() => {
|
||||
this.viewSaveTrigger(SaveSettingsStep.Idle);
|
||||
}, Magics.Time1s);
|
||||
}
|
||||
},
|
||||
requestUid,
|
||||
this.viewID(),
|
||||
properties
|
||||
);
|
||||
}
|
||||
|
||||
@command((self) => !self.contacts.syncing() && !self.contacts.importing())
|
||||
syncCommand() {
|
||||
getApp().contactsSync((result, data) => {
|
||||
if (StorageResultType.Success !== result || !data || !data.Result)
|
||||
{
|
||||
window.alert(getNotification(
|
||||
data && data.ErrorCode ? data.ErrorCode : Notification.ContactsSyncError));
|
||||
if (StorageResultType.Success !== result || !data || !data.Result) {
|
||||
window.alert(getNotification(data && data.ErrorCode ? data.ErrorCode : Notification.ContactsSyncError));
|
||||
}
|
||||
|
||||
this.reloadContactList(true);
|
||||
|
|
@ -381,8 +372,7 @@ class ContactsPopupView extends AbstractViewNext
|
|||
|
||||
getPropertyPlaceholder(type) {
|
||||
let result = '';
|
||||
switch (type)
|
||||
{
|
||||
switch (type) {
|
||||
case ContactPropertyType.LastName:
|
||||
result = 'CONTACTS/PLACEHOLDER_ENTER_LAST_NAME';
|
||||
break;
|
||||
|
|
@ -399,17 +389,16 @@ class ContactsPopupView extends AbstractViewNext
|
|||
}
|
||||
|
||||
addNewProperty(type, typeStr) {
|
||||
this.viewProperties.push(new ContactPropertyModel(type, typeStr || '', '', true, this.getPropertyPlaceholder(type)));
|
||||
this.viewProperties.push(
|
||||
new ContactPropertyModel(type, typeStr || '', '', true, this.getPropertyPlaceholder(type))
|
||||
);
|
||||
}
|
||||
|
||||
addNewOrFocusProperty(type, typeStr) {
|
||||
const item = _.find(this.viewProperties(), (prop) => type === prop.type());
|
||||
if (item)
|
||||
{
|
||||
if (item) {
|
||||
item.focused(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.addNewProperty(type, typeStr);
|
||||
}
|
||||
}
|
||||
|
|
@ -447,53 +436,42 @@ class ContactsPopupView extends AbstractViewNext
|
|||
}
|
||||
|
||||
initUploader() {
|
||||
if (this.importUploaderButton())
|
||||
{
|
||||
const
|
||||
j = new Jua({
|
||||
'action': uploadContacts(),
|
||||
'name': 'uploader',
|
||||
'queueSize': 1,
|
||||
'multipleSizeLimit': 1,
|
||||
'disableDragAndDrop': true,
|
||||
'disableMultiple': true,
|
||||
'disableDocumentDropPrevent': true,
|
||||
'clickElement': this.importUploaderButton()
|
||||
});
|
||||
if (this.importUploaderButton()) {
|
||||
const j = new Jua({
|
||||
'action': uploadContacts(),
|
||||
'name': 'uploader',
|
||||
'queueSize': 1,
|
||||
'multipleSizeLimit': 1,
|
||||
'disableDragAndDrop': true,
|
||||
'disableMultiple': true,
|
||||
'disableDocumentDropPrevent': true,
|
||||
'clickElement': this.importUploaderButton()
|
||||
});
|
||||
|
||||
if (j)
|
||||
{
|
||||
j
|
||||
.on('onStart', () => {
|
||||
this.contacts.importing(true);
|
||||
})
|
||||
.on('onComplete', (id, result, data) => {
|
||||
this.contacts.importing(false);
|
||||
this.reloadContactList();
|
||||
if (!id || !result || !data || !data.Result)
|
||||
{
|
||||
window.alert(i18n('CONTACTS/ERROR_IMPORT_FILE'));
|
||||
}
|
||||
});
|
||||
if (j) {
|
||||
j.on('onStart', () => {
|
||||
this.contacts.importing(true);
|
||||
}).on('onComplete', (id, result, data) => {
|
||||
this.contacts.importing(false);
|
||||
this.reloadContactList();
|
||||
if (!id || !result || !data || !data.Result) {
|
||||
window.alert(i18n('CONTACTS/ERROR_IMPORT_FILE'));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
removeCheckedOrSelectedContactsFromList() {
|
||||
const
|
||||
koContacts = this.contacts,
|
||||
const koContacts = this.contacts,
|
||||
contacts = this.contactsCheckedOrSelected();
|
||||
|
||||
let
|
||||
currentContact = this.currentContact(),
|
||||
let currentContact = this.currentContact(),
|
||||
count = this.contacts().length;
|
||||
|
||||
if (0 < contacts.length)
|
||||
{
|
||||
if (0 < contacts.length) {
|
||||
_.each(contacts, (contact) => {
|
||||
|
||||
if (currentContact && currentContact.idContact === contact.idContact)
|
||||
{
|
||||
if (currentContact && currentContact.idContact === contact.idContact) {
|
||||
currentContact = null;
|
||||
this.currentContact(null);
|
||||
}
|
||||
|
|
@ -502,8 +480,7 @@ class ContactsPopupView extends AbstractViewNext
|
|||
count -= 1;
|
||||
});
|
||||
|
||||
if (0 >= count)
|
||||
{
|
||||
if (0 >= count) {
|
||||
this.bDropPageAfterDelete = true;
|
||||
}
|
||||
|
||||
|
|
@ -517,12 +494,8 @@ class ContactsPopupView extends AbstractViewNext
|
|||
}
|
||||
|
||||
deleteSelectedContacts() {
|
||||
if (0 < this.contactsCheckedOrSelected().length)
|
||||
{
|
||||
Remote.contactsDelete(
|
||||
_.bind(this.deleteResponse, this),
|
||||
this.contactsCheckedOrSelectedUids()
|
||||
);
|
||||
if (0 < this.contactsCheckedOrSelected().length) {
|
||||
Remote.contactsDelete(_.bind(this.deleteResponse, this), this.contactsCheckedOrSelectedUids());
|
||||
|
||||
this.removeCheckedOrSelectedContactsFromList();
|
||||
}
|
||||
|
|
@ -533,12 +506,9 @@ class ContactsPopupView extends AbstractViewNext
|
|||
* @param {AjaxJsonDefaultResponse} oData
|
||||
*/
|
||||
deleteResponse(sResult, oData) {
|
||||
if (Magics.Time500ms < (StorageResultType.Success === sResult && oData && oData.Time ? pInt(oData.Time) : 0))
|
||||
{
|
||||
if (Magics.Time500ms < (StorageResultType.Success === sResult && oData && oData.Time ? pInt(oData.Time) : 0)) {
|
||||
this.reloadContactList(this.bDropPageAfterDelete);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
_.delay(() => {
|
||||
this.reloadContactList(this.bDropPageAfterDelete);
|
||||
}, Magics.Time500ms);
|
||||
|
|
@ -554,36 +524,26 @@ class ContactsPopupView extends AbstractViewNext
|
|||
* @param {?ContactModel} contact
|
||||
*/
|
||||
populateViewContact(contact) {
|
||||
let
|
||||
id = '',
|
||||
let id = '',
|
||||
lastName = '',
|
||||
firstName = '';
|
||||
const
|
||||
list = [];
|
||||
const list = [];
|
||||
|
||||
this.watchHash(false);
|
||||
|
||||
this.emptySelection(false);
|
||||
this.viewReadOnly(false);
|
||||
|
||||
if (contact)
|
||||
{
|
||||
if (contact) {
|
||||
id = contact.idContact;
|
||||
if (isNonEmptyArray(contact.properties))
|
||||
{
|
||||
if (isNonEmptyArray(contact.properties)) {
|
||||
_.each(contact.properties, (property) => {
|
||||
if (property && property[0])
|
||||
{
|
||||
if (ContactPropertyType.LastName === property[0])
|
||||
{
|
||||
if (property && property[0]) {
|
||||
if (ContactPropertyType.LastName === property[0]) {
|
||||
lastName = property[1];
|
||||
}
|
||||
else if (ContactPropertyType.FirstName === property[0])
|
||||
{
|
||||
} else if (ContactPropertyType.FirstName === property[0]) {
|
||||
firstName = property[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
list.push(new ContactPropertyModel(property[0], property[2] || '', property[1]));
|
||||
}
|
||||
}
|
||||
|
|
@ -593,11 +553,25 @@ class ContactsPopupView extends AbstractViewNext
|
|||
this.viewReadOnly(!!contact.readOnly);
|
||||
}
|
||||
|
||||
list.unshift(new ContactPropertyModel(ContactPropertyType.LastName, '', lastName, false,
|
||||
this.getPropertyPlaceholder(ContactPropertyType.LastName)));
|
||||
list.unshift(
|
||||
new ContactPropertyModel(
|
||||
ContactPropertyType.LastName,
|
||||
'',
|
||||
lastName,
|
||||
false,
|
||||
this.getPropertyPlaceholder(ContactPropertyType.LastName)
|
||||
)
|
||||
);
|
||||
|
||||
list.unshift(new ContactPropertyModel(ContactPropertyType.FirstName, '', firstName, !contact,
|
||||
this.getPropertyPlaceholder(ContactPropertyType.FirstName)));
|
||||
list.unshift(
|
||||
new ContactPropertyModel(
|
||||
ContactPropertyType.FirstName,
|
||||
'',
|
||||
firstName,
|
||||
!contact,
|
||||
this.getPropertyPlaceholder(ContactPropertyType.FirstName)
|
||||
)
|
||||
);
|
||||
|
||||
this.viewID(id);
|
||||
|
||||
|
|
@ -614,49 +588,47 @@ class ContactsPopupView extends AbstractViewNext
|
|||
* @param {boolean=} dropPagePosition = false
|
||||
*/
|
||||
reloadContactList(dropPagePosition = false) {
|
||||
|
||||
let offset = (this.contactsPage() - 1) * CONTACTS_PER_PAGE;
|
||||
|
||||
this.bDropPageAfterDelete = false;
|
||||
|
||||
if (dropPagePosition)
|
||||
{
|
||||
if (dropPagePosition) {
|
||||
this.contactsPage(1);
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
this.contacts.loading(true);
|
||||
Remote.contacts((result, data) => {
|
||||
Remote.contacts(
|
||||
(result, data) => {
|
||||
let count = 0,
|
||||
list = [];
|
||||
|
||||
let
|
||||
count = 0,
|
||||
list = [];
|
||||
if (StorageResultType.Success === result && data && data.Result && data.Result.List) {
|
||||
if (isNonEmptyArray(data.Result.List)) {
|
||||
list = _.map(data.Result.List, (item) => {
|
||||
const contact = new ContactModel();
|
||||
return contact.parse(item) ? contact : null;
|
||||
});
|
||||
|
||||
if (StorageResultType.Success === result && data && data.Result && data.Result.List)
|
||||
{
|
||||
if (isNonEmptyArray(data.Result.List))
|
||||
{
|
||||
list = _.map(data.Result.List, (item) => {
|
||||
const contact = new ContactModel();
|
||||
return contact.parse(item) ? contact : null;
|
||||
});
|
||||
list = _.compact(list);
|
||||
|
||||
list = _.compact(list);
|
||||
|
||||
count = pInt(data.Result.Count);
|
||||
count = 0 < count ? count : 0;
|
||||
count = pInt(data.Result.Count);
|
||||
count = 0 < count ? count : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.contactsCount(count);
|
||||
this.contactsCount(count);
|
||||
|
||||
delegateRunOnDestroy(this.contacts());
|
||||
this.contacts(list);
|
||||
delegateRunOnDestroy(this.contacts());
|
||||
this.contacts(list);
|
||||
|
||||
this.contacts.loading(false);
|
||||
this.viewClearSearch('' !== this.search());
|
||||
|
||||
}, offset, CONTACTS_PER_PAGE, this.search());
|
||||
this.contacts.loading(false);
|
||||
this.viewClearSearch('' !== this.search());
|
||||
},
|
||||
offset,
|
||||
CONTACTS_PER_PAGE,
|
||||
this.search()
|
||||
);
|
||||
}
|
||||
|
||||
onBuild(dom) {
|
||||
|
|
@ -677,15 +649,14 @@ class ContactsPopupView extends AbstractViewNext
|
|||
|
||||
const self = this;
|
||||
|
||||
dom
|
||||
.on('click', '.e-pagenator .e-page', function() { // eslint-disable-line prefer-arrow-callback
|
||||
const page = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
||||
if (page)
|
||||
{
|
||||
self.contactsPage(pInt(page.value));
|
||||
self.reloadContactList();
|
||||
}
|
||||
});
|
||||
dom.on('click', '.e-pagenator .e-page', function() {
|
||||
// eslint-disable-line prefer-arrow-callback
|
||||
const page = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
||||
if (page) {
|
||||
self.contactsPage(pInt(page.value));
|
||||
self.reloadContactList();
|
||||
}
|
||||
});
|
||||
|
||||
this.initUploader();
|
||||
}
|
||||
|
|
@ -711,16 +682,14 @@ class ContactsPopupView extends AbstractViewNext
|
|||
|
||||
this.sLastComposeFocusedField = '';
|
||||
|
||||
if (this.bBackToCompose)
|
||||
{
|
||||
if (this.bBackToCompose) {
|
||||
this.bBackToCompose = false;
|
||||
|
||||
if (Settings.capa(Capa.Composer))
|
||||
{
|
||||
if (Settings.capa(Capa.Composer)) {
|
||||
showScreenPopup(require('View/Popup/Compose'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {ContactsPopupView, ContactsPopupView as default};
|
||||
export { ContactsPopupView, ContactsPopupView as default };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue