mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 03:29:20 +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,6 +9,7 @@ function AdminContacts()
|
|||
|
||||
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
|
||||
this.enableContacts = ko.observable(!!RL.settingsGet('ContactsEnable'));
|
||||
this.contactsSharing = ko.observable(!!RL.settingsGet('ContactsSharing'));
|
||||
|
||||
var
|
||||
aTypes = ['sqlite', 'mysql', 'pgsql'],
|
||||
|
|
@ -176,6 +177,12 @@ AdminContacts.prototype.onBuild = function ()
|
|||
'ContactsEnable': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
self.contactsSharing.subscribe(function (bValue) {
|
||||
RL.remote().saveAdminConfig(null, {
|
||||
'ContactsSharing': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
self.contactsType.subscribe(function (sValue) {
|
||||
RL.remote().saveAdminConfig(f5, {
|
||||
|
|
|
|||
|
|
@ -238,12 +238,7 @@ Enums.InterfaceAnimation = {
|
|||
Enums.ContactScopeType = {
|
||||
|
||||
'Default': 0,
|
||||
|
||||
'Auto': 1,
|
||||
|
||||
'ShareAll': 2,
|
||||
'ShareDomain': 3,
|
||||
'ShareEmail': 4
|
||||
'ShareAll': 2
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -719,6 +719,7 @@ Utils.initDataConstructorBySettings = function (oData)
|
|||
oData.editorDefaultType = ko.observable(Enums.EditorDefaultType.Html);
|
||||
oData.showImages = ko.observable(false);
|
||||
oData.interfaceAnimation = ko.observable(Enums.InterfaceAnimation.Full);
|
||||
oData.contactsAutosave = ko.observable(false);
|
||||
|
||||
Globals.sAnimationType = Enums.InterfaceAnimation.Full;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ function ContactModel()
|
|||
this.properties = [];
|
||||
this.readOnly = false;
|
||||
this.scopeType = Enums.ContactScopeType.Default;
|
||||
this.scopeValue = '';
|
||||
|
||||
this.checked = ko.observable(false);
|
||||
this.selected = ko.observable(false);
|
||||
|
|
@ -61,7 +60,6 @@ ContactModel.prototype.parse = function (oItem)
|
|||
this.display = Utils.pString(oItem['Display']);
|
||||
this.readOnly = !!oItem['ReadOnly'];
|
||||
this.scopeType = Utils.pInt(oItem['ScopeType']);
|
||||
this.scopeValue = Utils.pString(oItem['ScopeValue']);
|
||||
|
||||
if (Utils.isNonEmptyArray(oItem['Properties']))
|
||||
{
|
||||
|
|
@ -73,10 +71,7 @@ ContactModel.prototype.parse = function (oItem)
|
|||
}, this);
|
||||
}
|
||||
|
||||
this.shared(-1 < Utils.inArray(this.scopeType, [
|
||||
Enums.ContactScopeType.ShareAll, Enums.ContactScopeType.ShareDomain, Enums.ContactScopeType.ShareEmail
|
||||
]));
|
||||
|
||||
this.shared(Enums.ContactScopeType.ShareAll === this.scopeType);
|
||||
bResult = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,20 @@
|
|||
* @param {number=} iType = Enums.ContactPropertyType.Unknown
|
||||
* @param {string=} sValue = ''
|
||||
* @param {boolean=} bFocused = false
|
||||
* @param {string=} sPlaceholder = ''
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
function ContactPropertyModel(iType, sValue, bFocused)
|
||||
function ContactPropertyModel(iType, sValue, bFocused, sPlaceholder)
|
||||
{
|
||||
this.type = ko.observable(Utils.isUnd(iType) ? Enums.ContactPropertyType.Unknown : iType);
|
||||
this.focused = ko.observable(Utils.isUnd(bFocused) ? false : !!bFocused);
|
||||
this.value = ko.observable(Utils.pString(sValue));
|
||||
|
||||
this.placeholder = ko.observable(sPlaceholder || '');
|
||||
|
||||
this.placeholderValue = ko.computed(function () {
|
||||
var sPlaceholder = this.placeholder();
|
||||
return sPlaceholder ? Utils.i18n(sPlaceholder) : '';
|
||||
}, this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ function SettingsGeneral()
|
|||
this.mainMessagesPerPageArray = Consts.Defaults.MessagesPerPageArray;
|
||||
this.editorDefaultType = oData.editorDefaultType;
|
||||
this.showImages = oData.showImages;
|
||||
this.contactsAutosave = oData.contactsAutosave;
|
||||
this.interfaceAnimation = oData.interfaceAnimation;
|
||||
this.useDesktopNotifications = oData.useDesktopNotifications;
|
||||
this.threading = oData.threading;
|
||||
|
|
@ -95,6 +96,12 @@ SettingsGeneral.prototype.onBuild = function ()
|
|||
});
|
||||
});
|
||||
|
||||
oData.contactsAutosave.subscribe(function (bValue) {
|
||||
RL.remote().saveSettings(Utils.emptyFunction, {
|
||||
'ContactsAutosave': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
oData.interfaceAnimation.subscribe(function (sValue) {
|
||||
RL.remote().saveSettings(Utils.emptyFunction, {
|
||||
'InterfaceAnimation': sValue
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ AbstractData.prototype.populateDataOnStart = function()
|
|||
|
||||
this.editorDefaultType(RL.settingsGet('EditorDefaultType'));
|
||||
this.showImages(!!RL.settingsGet('ShowImages'));
|
||||
this.contactsAutosave(!!RL.settingsGet('ContactsAutosave'));
|
||||
this.interfaceAnimation(RL.settingsGet('InterfaceAnimation'));
|
||||
|
||||
this.mainMessagesPerPage(RL.settingsGet('MPP'));
|
||||
|
|
|
|||
|
|
@ -570,11 +570,12 @@ WebMailAjaxRemoteStorage.prototype.contacts = function (fCallback, iOffset, iLim
|
|||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
WebMailAjaxRemoteStorage.prototype.contactSave = function (fCallback, sRequestUid, sUid, aProperties)
|
||||
WebMailAjaxRemoteStorage.prototype.contactSave = function (fCallback, sRequestUid, sUid, nScopeType, aProperties)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'ContactSave', {
|
||||
'RequestUid': sRequestUid,
|
||||
'Uid': Utils.trim(sUid),
|
||||
'ScopeType': nScopeType,
|
||||
'Properties': aProperties
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@
|
|||
|
||||
.control-group {
|
||||
.control-label.fix-width {
|
||||
width: 110px;
|
||||
width: 90px;
|
||||
}
|
||||
.controls.fix-width {
|
||||
margin-left: 135px;
|
||||
margin-left: 110px;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -319,6 +319,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
.e-save-trigger {
|
||||
position: absolute;
|
||||
top: 25px;
|
||||
left: 10px;
|
||||
}
|
||||
|
||||
.e-read-only-sign {
|
||||
display: none;
|
||||
position: absolute;
|
||||
|
|
@ -328,14 +334,14 @@
|
|||
|
||||
.e-share-sign {
|
||||
position: absolute;
|
||||
top: 60px;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.button-save-contact {
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
top: 100px;
|
||||
right: 20px;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,10 @@
|
|||
cursor: pointer;
|
||||
}
|
||||
|
||||
.e-item.selected > .e-link {
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
.e-item > .e-link:hover {
|
||||
background-color: #555;
|
||||
background-image: none;
|
||||
|
|
|
|||
|
|
@ -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