mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-11 00:14:50 +03:00
Added functionality to share contacts
Added setting "Automatically add recipients to your address beech" Further development of editing screen contact
This commit is contained in:
parent
026839d864
commit
2d9ff7d63f
63 changed files with 1229 additions and 1919 deletions
|
|
@ -9,8 +9,8 @@ function PopupsContactsViewModel()
|
|||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsContacts');
|
||||
|
||||
var
|
||||
oT = Enums.ContactPropertyType,
|
||||
self = this,
|
||||
oT = Enums.ContactPropertyType,
|
||||
aNameTypes = [oT.FullName, oT.FirstName, oT.SurName, oT.MiddleName],
|
||||
aEmailTypes = [oT.EmailPersonal, oT.EmailBussines, oT.EmailOther],
|
||||
aPhonesTypes = [
|
||||
|
|
@ -34,6 +34,8 @@ function PopupsContactsViewModel()
|
|||
this.contacts.loading = ko.observable(false).extend({'throttle': 200});
|
||||
this.currentContact = ko.observable(null);
|
||||
|
||||
this.contactsSharingIsAllowed = !!RL.settingsGet('ContactsSharingIsAllowed');
|
||||
|
||||
this.contactsPage = ko.observable(1);
|
||||
this.contactsPageCount = ko.computed(function () {
|
||||
var iPage = Math.ceil(this.contactsCount() / Consts.Defaults.ContactsPerPage);
|
||||
|
|
@ -48,9 +50,10 @@ function PopupsContactsViewModel()
|
|||
this.viewID = ko.observable('');
|
||||
this.viewReadOnly = ko.observable(false);
|
||||
this.viewScopeType = ko.observable(Enums.ContactScopeType.Default);
|
||||
this.viewScopeValue = ko.observable('');
|
||||
this.viewProperties = ko.observableArray([]);
|
||||
|
||||
this.viewSaveTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
|
||||
this.viewPropertiesNames = this.viewProperties.filter(function(oProperty) {
|
||||
return -1 < Utils.inArray(oProperty.type(), aNameTypes);
|
||||
});
|
||||
|
|
@ -59,24 +62,18 @@ function PopupsContactsViewModel()
|
|||
return -1 < Utils.inArray(oProperty.type(), aEmailTypes);
|
||||
});
|
||||
|
||||
this.shareIcon = ko.computed(function() {
|
||||
return Enums.ContactScopeType.ShareAll === this.viewScopeType() ? 'icon-earth' : 'icon-share';
|
||||
}, this);
|
||||
|
||||
this.shareToNone = ko.computed(function() {
|
||||
return -1 === Utils.inArray(this.viewScopeType(), [
|
||||
Enums.ContactScopeType.ShareAll, Enums.ContactScopeType.ShareDomain, Enums.ContactScopeType.ShareEmail
|
||||
]);
|
||||
return Enums.ContactScopeType.ShareAll !== this.viewScopeType();
|
||||
}, this);
|
||||
|
||||
this.shareToAll = ko.computed(function() {
|
||||
return Enums.ContactScopeType.ShareAll === this.viewScopeType();
|
||||
}, this);
|
||||
|
||||
this.shareToDomain = ko.computed(function() {
|
||||
return Enums.ContactScopeType.ShareDomain === this.viewScopeType();
|
||||
}, this);
|
||||
|
||||
this.shareToEmail = ko.computed(function() {
|
||||
return Enums.ContactScopeType.ShareEmail === this.viewScopeType();
|
||||
}, this);
|
||||
|
||||
this.viewHasNonEmptyRequaredProperties = ko.computed(function() {
|
||||
|
||||
var
|
||||
|
|
@ -98,6 +95,10 @@ function PopupsContactsViewModel()
|
|||
return -1 < Utils.inArray(oProperty.type(), aOtherTypes);
|
||||
});
|
||||
|
||||
this.viewPropertiesEmailsNonEmpty = this.viewPropertiesNames.filter(function(oProperty) {
|
||||
return '' !== Utils.trim(oProperty.value());
|
||||
});
|
||||
|
||||
this.viewPropertiesEmailsEmptyAndOnFocused = this.viewPropertiesEmails.filter(function(oProperty) {
|
||||
var bF = oProperty.focused();
|
||||
return '' === Utils.trim(oProperty.value()) && !bF;
|
||||
|
|
@ -223,6 +224,7 @@ function PopupsContactsViewModel()
|
|||
this.saveCommand = Utils.createCommand(this, function () {
|
||||
|
||||
this.viewSaving(true);
|
||||
this.viewSaveTrigger(Enums.SaveSettingsStep.Animate);
|
||||
|
||||
var
|
||||
sRequestUid = Utils.fakeMd5(),
|
||||
|
|
@ -238,7 +240,9 @@ function PopupsContactsViewModel()
|
|||
|
||||
RL.remote().contactSave(function (sResult, oData) {
|
||||
|
||||
var bRes = false;
|
||||
self.viewSaving(false);
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result &&
|
||||
oData.Result.RequestUid === sRequestUid && 0 < Utils.pInt(oData.Result.ResultID))
|
||||
{
|
||||
|
|
@ -248,13 +252,25 @@ function PopupsContactsViewModel()
|
|||
}
|
||||
|
||||
self.reloadContactList();
|
||||
bRes = true;
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// // TODO
|
||||
// }
|
||||
|
||||
_.delay(function () {
|
||||
self.viewSaveTrigger(bRes ? Enums.SaveSettingsStep.TrueResult : Enums.SaveSettingsStep.FalseResult);
|
||||
}, 300);
|
||||
|
||||
if (bRes)
|
||||
{
|
||||
_.delay(function () {
|
||||
self.viewSaveTrigger(Enums.SaveSettingsStep.Idle);
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
}, sRequestUid, this.viewID(), aProperties);
|
||||
}, sRequestUid, this.viewID(), this.viewScopeType(), aProperties);
|
||||
|
||||
}, function () {
|
||||
var
|
||||
|
|
@ -266,11 +282,36 @@ function PopupsContactsViewModel()
|
|||
|
||||
this.bDropPageAfterDelete = false;
|
||||
|
||||
this.watchHash = ko.observable(false);
|
||||
this.viewHash = ko.computed(function () {
|
||||
return '' + self.viewScopeType() + ' - ' + _.map(self.viewProperties(), function (oItem) {
|
||||
return oItem.value();
|
||||
}).join('');
|
||||
});
|
||||
|
||||
this.saveCommandDebounce = _.debounce(_.bind(this.saveCommand, this), 1000);
|
||||
|
||||
this.viewHash.subscribe(function () {
|
||||
if (this.watchHash() && !this.viewReadOnly())
|
||||
{
|
||||
this.saveCommandDebounce();
|
||||
}
|
||||
}, this);
|
||||
|
||||
Knoin.constructorEnd(this);
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsContactsViewModel', PopupsContactsViewModel);
|
||||
|
||||
PopupsContactsViewModel.prototype.setShareToNone = function ()
|
||||
{
|
||||
this.viewScopeType(Enums.ContactScopeType.Default);
|
||||
};
|
||||
|
||||
PopupsContactsViewModel.prototype.setShareToAll = function ()
|
||||
{
|
||||
this.viewScopeType(Enums.ContactScopeType.ShareAll);
|
||||
};
|
||||
|
||||
PopupsContactsViewModel.prototype.addNewProperty = function (sType)
|
||||
{
|
||||
|
|
@ -377,10 +418,11 @@ PopupsContactsViewModel.prototype.populateViewContact = function (oContact)
|
|||
aList = []
|
||||
;
|
||||
|
||||
this.watchHash(false);
|
||||
|
||||
this.emptySelection(false);
|
||||
this.viewReadOnly(false);
|
||||
this.viewScopeType(Enums.ContactScopeType.Default);
|
||||
this.viewScopeValue('');
|
||||
|
||||
if (oContact)
|
||||
{
|
||||
|
|
@ -391,7 +433,9 @@ PopupsContactsViewModel.prototype.populateViewContact = function (oContact)
|
|||
_.each(oContact.properties, function (aProperty) {
|
||||
if (aProperty && aProperty[0])
|
||||
{
|
||||
aList.push(new ContactPropertyModel(aProperty[0], aProperty[1]));
|
||||
aList.push(new ContactPropertyModel(aProperty[0], aProperty[1], false,
|
||||
Enums.ContactPropertyType.FullName === aProperty[0] ? 'CONTACTS/PLACEHOLDER_ENTER_DISPLAY_NAME' : ''));
|
||||
|
||||
if (Enums.ContactPropertyType.FullName === aProperty[0])
|
||||
{
|
||||
bHasName = true;
|
||||
|
|
@ -402,17 +446,18 @@ PopupsContactsViewModel.prototype.populateViewContact = function (oContact)
|
|||
|
||||
this.viewReadOnly(!!oContact.readOnly);
|
||||
this.viewScopeType(oContact.scopeType);
|
||||
this.viewScopeValue(oContact.scopeValue);
|
||||
}
|
||||
|
||||
|
||||
if (!bHasName)
|
||||
{
|
||||
aList.push(new ContactPropertyModel(Enums.ContactPropertyType.FullName, '', true));
|
||||
aList.push(new ContactPropertyModel(Enums.ContactPropertyType.FullName, '', !oContact, 'CONTACTS/PLACEHOLDER_ENTER_DISPLAY_NAME'));
|
||||
}
|
||||
|
||||
this.viewID(sId);
|
||||
this.viewProperties([]);
|
||||
this.viewProperties(aList);
|
||||
|
||||
this.watchHash(true);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -446,7 +491,7 @@ PopupsContactsViewModel.prototype.reloadContactList = function (bDropPagePositio
|
|||
{
|
||||
aList = _.map(oData.Result.List, function (oItem) {
|
||||
var oContact = new ContactModel();
|
||||
return oContact.parse(oItem) ? oContact : null;
|
||||
return oContact.parse(oItem, self.contactsSharingIsAllowed) ? oContact : null;
|
||||
});
|
||||
|
||||
aList = _.compact(aList);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue