mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-08 22:18:28 +03:00
Merge new-contacts-api
New interface Contact storage move to plugin
This commit is contained in:
commit
efdca7ef77
44 changed files with 3454 additions and 1012 deletions
|
|
@ -35,8 +35,6 @@ function AdminGeneral()
|
|||
return Utils.convertLangName(this.mainLanguage());
|
||||
}, this);
|
||||
|
||||
this.contactsSupported = RL.settingsGet('ContactsIsSupported');
|
||||
this.contactsIsAllowed = RL.settingsGet('ContactsIsAllowed');
|
||||
this.weakPassword = !!RL.settingsGet('WeakPassword');
|
||||
|
||||
this.titleTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
|
||||
|
|
|
|||
|
|
@ -539,9 +539,9 @@ RainLoopApp.prototype.getAutocomplete = function (sQuery, fCallback)
|
|||
;
|
||||
|
||||
RL.remote().suggestions(function (sResult, oData) {
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && Utils.isArray(oData.Result.List))
|
||||
if (Enums.StorageResultType.Success === sResult && oData && Utils.isArray(oData.Result))
|
||||
{
|
||||
aData = _.map(oData.Result.List, function (aItem) {
|
||||
aData = _.map(oData.Result, function (aItem) {
|
||||
return aItem && aItem[0] ? new EmailModel(aItem[0], aItem[1]) : null;
|
||||
});
|
||||
|
||||
|
|
@ -551,6 +551,7 @@ RainLoopApp.prototype.getAutocomplete = function (sQuery, fCallback)
|
|||
{
|
||||
fCallback([]);
|
||||
}
|
||||
|
||||
}, sQuery);
|
||||
};
|
||||
|
||||
|
|
@ -578,7 +579,7 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
bTwitter = RL.settingsGet('AllowTwitterSocial')
|
||||
;
|
||||
|
||||
if (!RL.settingsGet('AllowChangePassword'))
|
||||
if (!RL.settingsGet('ChangePasswordIsAllowed'))
|
||||
{
|
||||
Utils.removeSettingsViewModel(SettingsChangePasswordScreen);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -231,6 +231,45 @@ Enums.InterfaceAnimation = {
|
|||
'Full': 'Full'
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.ContactPropertyType = {
|
||||
|
||||
'Unknown': 0,
|
||||
|
||||
'FullName': 10,
|
||||
|
||||
'FirstName': 15,
|
||||
'SurName': 16,
|
||||
'MiddleName': 17,
|
||||
'Nick': 18,
|
||||
|
||||
'EmailPersonal': 30,
|
||||
'EmailBussines': 31,
|
||||
'EmailOther': 32,
|
||||
|
||||
'PhonePersonal': 50,
|
||||
'PhoneBussines': 51,
|
||||
'PhoneOther': 52,
|
||||
|
||||
'MobilePersonal': 60,
|
||||
'MobileBussines': 61,
|
||||
'MobileOther': 62,
|
||||
|
||||
'FaxPesonal': 70,
|
||||
'FaxBussines': 71,
|
||||
'FaxOther': 72,
|
||||
|
||||
'Facebook': 90,
|
||||
'Skype': 91,
|
||||
'GitHub': 92,
|
||||
|
||||
'Description': 110,
|
||||
|
||||
'Custom': 250
|
||||
};
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -631,6 +631,12 @@ ko.extenders.falseTimeout = function (oTarget, iOption)
|
|||
return oTarget;
|
||||
};
|
||||
|
||||
ko.observable.fn.validateNone = function ()
|
||||
{
|
||||
this.hasError = ko.observable(false);
|
||||
return this;
|
||||
};
|
||||
|
||||
ko.observable.fn.validateEmail = function ()
|
||||
{
|
||||
this.hasError = ko.observable(false);
|
||||
|
|
|
|||
|
|
@ -886,7 +886,6 @@ Utils.initDataConstructorBySettings = function (oData)
|
|||
oData.dropboxEnable = ko.observable(false);
|
||||
oData.dropboxApiKey = ko.observable('');
|
||||
|
||||
oData.contactsIsSupported = ko.observable(false);
|
||||
oData.contactsIsAllowed = ko.observable(false);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -6,26 +6,65 @@
|
|||
function ContactModel()
|
||||
{
|
||||
this.idContact = 0;
|
||||
this.imageHash = '';
|
||||
this.listName = '';
|
||||
this.name = '';
|
||||
this.emails = [];
|
||||
this.display = '';
|
||||
this.properties = [];
|
||||
|
||||
this.checked = ko.observable(false);
|
||||
this.selected = ko.observable(false);
|
||||
this.deleted = ko.observable(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {Array|null}
|
||||
*/
|
||||
ContactModel.prototype.getNameAndEmailHelper = function ()
|
||||
{
|
||||
var
|
||||
sName = '',
|
||||
sEmail = ''
|
||||
;
|
||||
|
||||
if (Utils.isNonEmptyArray(this.properties))
|
||||
{
|
||||
_.each(this.properties, function (aProperty) {
|
||||
if (aProperty)
|
||||
{
|
||||
if ('' === sName && Enums.ContactPropertyType.FullName === aProperty[0])
|
||||
{
|
||||
sName = aProperty[1];
|
||||
}
|
||||
else if ('' === sEmail && -1 < Utils.inArray(aProperty[0], [
|
||||
Enums.ContactPropertyType.EmailPersonal,
|
||||
Enums.ContactPropertyType.EmailBussines,
|
||||
Enums.ContactPropertyType.EmailOther
|
||||
]))
|
||||
{
|
||||
sEmail = aProperty[1];
|
||||
}
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
|
||||
return '' === sEmail ? null : [sEmail, sName];
|
||||
};
|
||||
|
||||
ContactModel.prototype.parse = function (oItem)
|
||||
{
|
||||
var bResult = false;
|
||||
if (oItem && 'Object/Contact' === oItem['@Object'])
|
||||
{
|
||||
this.idContact = Utils.pInt(oItem['IdContact']);
|
||||
this.listName = Utils.pString(oItem['ListName']);
|
||||
this.name = Utils.pString(oItem['Name']);
|
||||
this.emails = Utils.isNonEmptyArray(oItem['Emails']) ? oItem['Emails'] : [];
|
||||
this.imageHash = Utils.pString(oItem['ImageHash']);
|
||||
this.display = Utils.pString(oItem['Display']);
|
||||
|
||||
if (Utils.isNonEmptyArray(oItem['Properties']))
|
||||
{
|
||||
_.each(oItem['Properties'], function (oProperty) {
|
||||
if (oProperty && oProperty['Type'] && Utils.isNormal(oProperty['Value']))
|
||||
{
|
||||
this.properties.push([Utils.pInt(oProperty['Type']), Utils.pString(oProperty['Value'])]);
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
|
||||
bResult = true;
|
||||
}
|
||||
|
|
@ -38,8 +77,7 @@ ContactModel.prototype.parse = function (oItem)
|
|||
*/
|
||||
ContactModel.prototype.srcAttr = function ()
|
||||
{
|
||||
return '' === this.imageHash ? RL.link().emptyContactPic() :
|
||||
RL.link().getUserPicUrlFromHash(this.imageHash);
|
||||
return RL.link().emptyContactPic();
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
14
dev/Models/ContactPropertyModel.js
Normal file
14
dev/Models/ContactPropertyModel.js
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
||||
|
||||
/**
|
||||
* @param {number=} iType = Enums.ContactPropertyType.Unknown
|
||||
* @param {string=} sValue = ''
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
function ContactPropertyModel(iType, sValue)
|
||||
{
|
||||
this.type = ko.observable(Utils.isUnd(iType) ? Enums.ContactPropertyType.Unknown : iType);
|
||||
this.focused = ko.observable(false);
|
||||
this.value = ko.observable(Utils.pString(sValue));
|
||||
}
|
||||
|
|
@ -65,6 +65,5 @@ AbstractData.prototype.populateDataOnStart = function()
|
|||
this.dropboxEnable(!!RL.settingsGet('AllowDropboxSocial'));
|
||||
this.dropboxApiKey(RL.settingsGet('DropboxApiKey'));
|
||||
|
||||
this.contactsIsSupported(!!RL.settingsGet('ContactsIsSupported'));
|
||||
this.contactsIsAllowed(!!RL.settingsGet('ContactsIsAllowed'));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -538,11 +538,15 @@ WebMailAjaxRemoteStorage.prototype.quota = function (fCallback)
|
|||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {number} iOffset
|
||||
* @param {number} iLimit
|
||||
* @param {string} sSearch
|
||||
*/
|
||||
WebMailAjaxRemoteStorage.prototype.contacts = function (fCallback, sSearch)
|
||||
WebMailAjaxRemoteStorage.prototype.contacts = function (fCallback, iOffset, iLimit, sSearch)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'Contacts', {
|
||||
'Offset': iOffset,
|
||||
'Limit': iLimit,
|
||||
'Search': sSearch
|
||||
}, null, '', ['Contacts']);
|
||||
};
|
||||
|
|
@ -550,15 +554,12 @@ WebMailAjaxRemoteStorage.prototype.contacts = function (fCallback, sSearch)
|
|||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
WebMailAjaxRemoteStorage.prototype.contactSave = function (fCallback, sRequestUid, sUid, sName, sEmail, sImageData)
|
||||
WebMailAjaxRemoteStorage.prototype.contactSave = function (fCallback, sRequestUid, sUid, aProperties)
|
||||
{
|
||||
sUid = Utils.trim(sUid);
|
||||
this.defaultRequest(fCallback, 'ContactSave', {
|
||||
'RequestUid': sRequestUid,
|
||||
'Uid': sUid,
|
||||
'Name': sName,
|
||||
'Email': sEmail,
|
||||
'ImageData': sImageData
|
||||
'Uid': Utils.trim(sUid),
|
||||
'Properties': aProperties
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,303 +1,269 @@
|
|||
|
||||
@contacts-popup-left-width: 250px;
|
||||
|
||||
.b-contacts-content {
|
||||
|
||||
&.modal {
|
||||
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 900px;
|
||||
min-height: 300px;
|
||||
max-height: 700px;
|
||||
margin: auto;
|
||||
|
||||
.modal-body {
|
||||
overflow: auto;
|
||||
height: 100%;
|
||||
background-color: #f5f5f5;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.b-header-toolbar {
|
||||
|
||||
height: 40px;
|
||||
|
||||
background-color: @rlMainDarkColor;
|
||||
color: #fff;
|
||||
|
||||
background-color: #333;
|
||||
background-color: rgba(0,0,0,0.8) !important;
|
||||
|
||||
.close {
|
||||
color: #fff;
|
||||
.opacity(100);
|
||||
}
|
||||
|
||||
.btn {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.button-new-message {
|
||||
margin-left: 8px;
|
||||
}
|
||||
.button-delete {
|
||||
margin-left: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.b-list-toopbar {
|
||||
padding: 0;
|
||||
height: 45px;
|
||||
text-align: center;
|
||||
width: @contacts-popup-left-width;
|
||||
.box-shadow(inset 0 -1px 0 #ccc);
|
||||
|
||||
.e-search {
|
||||
margin-top: 7px;
|
||||
}
|
||||
}
|
||||
|
||||
.b-list-content {
|
||||
position: absolute;
|
||||
top: 45px;
|
||||
bottom: 60px;
|
||||
left: 0;
|
||||
width: @contacts-popup-left-width;
|
||||
overflow: hidden;
|
||||
overflow-y: auto;
|
||||
|
||||
.content {
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.listClear {
|
||||
color: #333;
|
||||
text-align: center;
|
||||
padding: 10px;
|
||||
font-size: 14px;
|
||||
line-height: 13px;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.listEmptyList, .listEmptyListLoading, .listEmptySearchList {
|
||||
color: #999;
|
||||
text-align: center;
|
||||
padding: 60px 10px;
|
||||
font-size: 24px;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
&.hideContactListCheckbox {
|
||||
.checkedParent, .checkboxCkeckAll {
|
||||
display: none !important;
|
||||
}
|
||||
.sidebarParent {
|
||||
margin-right: 10px !important;
|
||||
}
|
||||
}
|
||||
|
||||
.e-contact-foreach {
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.e-contact-item {
|
||||
position: relative;
|
||||
height: 45px;
|
||||
max-height: 45px;
|
||||
line-height: 45px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
|
||||
margin: 0px;
|
||||
border: 0px solid transparent;
|
||||
z-index: 100;
|
||||
|
||||
.delimiter {
|
||||
position: relative;
|
||||
display: block;
|
||||
height: 1px;
|
||||
background-color: #999;
|
||||
.opacity(20);
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.sidebarParent {
|
||||
display: inline-block;
|
||||
width: 6px;
|
||||
background-color: #eee;
|
||||
float: left;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
&.deleted {
|
||||
max-height: 0px;
|
||||
border-color: transparent !important;
|
||||
}
|
||||
|
||||
.checkedParent {
|
||||
display: inline-block;
|
||||
float: left;
|
||||
padding: 0 8px 0 6px;
|
||||
}
|
||||
|
||||
.nameParent {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: #333;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.nameParent, .emailParent {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.displayName, .displayEmail {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.displayImg {
|
||||
display: inline-block;
|
||||
float: right;
|
||||
position: relative;
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
&.checked {
|
||||
z-index: 101;
|
||||
|
||||
.sidebarParent {
|
||||
background-color: #69A8F5;
|
||||
}
|
||||
}
|
||||
|
||||
&.selected {
|
||||
background-color: #fff;
|
||||
z-index: 102;
|
||||
|
||||
.sidebarParent {
|
||||
background-color: #398CF2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.b-view-content {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 60px;
|
||||
left: @contacts-popup-left-width;
|
||||
right: 0;
|
||||
overflow: hidden;
|
||||
overflow-y: auto;
|
||||
|
||||
background-color: #fff;
|
||||
border-left: 1px solid #ddd;
|
||||
|
||||
.content {
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.b-contact-view-desc {
|
||||
text-align: center;
|
||||
font-size: 24px;
|
||||
line-height: 30px;
|
||||
padding-top: 120px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.top-part {
|
||||
margin-top: 20px;
|
||||
|
||||
.control-label {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.image-wrapper {
|
||||
margin-left: 30px;
|
||||
border-radius: 10px;
|
||||
|
||||
img {
|
||||
border-radius: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.top-row {
|
||||
padding: 10px 0;
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
.contactEmptyValueClick, .contactValueClick, .contactValueInput {
|
||||
display: inline-block;
|
||||
font-size: 24px;
|
||||
line-height: 28px;
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
.contactEmptyValueClick, .contactValueClick {
|
||||
color: #ddd;
|
||||
cursor: pointer;
|
||||
margin: 5px 0 0 7px;
|
||||
}
|
||||
|
||||
.contactValueInput {
|
||||
padding-left: 6px;
|
||||
}
|
||||
|
||||
.contactEmptyValueClick {
|
||||
border-bottom: 1px dashed #ddd;
|
||||
}
|
||||
|
||||
.contactValueClick {
|
||||
color: #555;
|
||||
border-bottom: 11px dashed transparent;
|
||||
}
|
||||
|
||||
.contactValueClick:hover {
|
||||
color: #000;
|
||||
border-bottom: 1px dashed #000;
|
||||
}
|
||||
|
||||
.contactValueInput {
|
||||
|
||||
}
|
||||
|
||||
.hasError {
|
||||
.contactValueClick, .contactValueInput {
|
||||
color: #ee5f5b;
|
||||
border: 1px solid #ee5f5b;
|
||||
}
|
||||
}
|
||||
|
||||
.button-save-contact {
|
||||
position: absolute;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.e-contact-item {
|
||||
|
||||
position: relative;
|
||||
height: 55px;
|
||||
max-height: 60px;
|
||||
line-height: 22px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
|
||||
margin: 0px;
|
||||
border: 0px solid transparent;
|
||||
z-index: 100;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@contacts-popup-left-width: 250px;
|
||||
|
||||
.b-contacts-content {
|
||||
|
||||
&.modal {
|
||||
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 900px;
|
||||
min-height: 300px;
|
||||
max-height: 700px;
|
||||
margin: auto;
|
||||
|
||||
.modal-body {
|
||||
overflow: auto;
|
||||
height: 100%;
|
||||
background-color: #f5f5f5;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.b-header-toolbar {
|
||||
|
||||
height: 40px;
|
||||
|
||||
background-color: @rlMainDarkColor;
|
||||
color: #fff;
|
||||
|
||||
background-color: #333;
|
||||
background-color: rgba(0,0,0,0.8) !important;
|
||||
|
||||
.close {
|
||||
color: #fff;
|
||||
.opacity(100);
|
||||
}
|
||||
|
||||
.btn {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.button-new-message {
|
||||
margin-left: 8px;
|
||||
}
|
||||
.button-delete {
|
||||
margin-left: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.b-list-toopbar {
|
||||
padding: 0;
|
||||
height: 45px;
|
||||
text-align: center;
|
||||
width: @contacts-popup-left-width;
|
||||
.box-shadow(inset 0 -1px 0 #ccc);
|
||||
|
||||
.e-search {
|
||||
margin-top: 7px;
|
||||
}
|
||||
}
|
||||
|
||||
.b-list-content {
|
||||
position: absolute;
|
||||
top: 45px;
|
||||
bottom: 60px;
|
||||
left: 0;
|
||||
width: @contacts-popup-left-width;
|
||||
overflow: hidden;
|
||||
overflow-y: auto;
|
||||
|
||||
.content {
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.listClear {
|
||||
color: #333;
|
||||
text-align: center;
|
||||
padding: 10px;
|
||||
font-size: 14px;
|
||||
line-height: 13px;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.listEmptyList, .listEmptyListLoading, .listEmptySearchList {
|
||||
color: #999;
|
||||
text-align: center;
|
||||
padding: 60px 10px;
|
||||
font-size: 24px;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
&.hideContactListCheckbox {
|
||||
.checkedParent, .checkboxCkeckAll {
|
||||
display: none !important;
|
||||
}
|
||||
.sidebarParent {
|
||||
margin-right: 10px !important;
|
||||
}
|
||||
}
|
||||
|
||||
.e-contact-foreach {
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.e-contact-item {
|
||||
position: relative;
|
||||
height: 45px;
|
||||
max-height: 45px;
|
||||
line-height: 45px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
|
||||
margin: 0px;
|
||||
border: 0px solid transparent;
|
||||
z-index: 100;
|
||||
|
||||
.delimiter {
|
||||
position: relative;
|
||||
display: block;
|
||||
height: 1px;
|
||||
background-color: #999;
|
||||
.opacity(20);
|
||||
}
|
||||
|
||||
.wrapper {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.sidebarParent {
|
||||
display: inline-block;
|
||||
width: 6px;
|
||||
background-color: #eee;
|
||||
float: left;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
&.deleted {
|
||||
max-height: 0px;
|
||||
border-color: transparent !important;
|
||||
}
|
||||
|
||||
.checkedParent {
|
||||
display: inline-block;
|
||||
float: left;
|
||||
padding: 0 8px 0 6px;
|
||||
}
|
||||
|
||||
.nameParent {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: #333;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.nameParent, .emailParent {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.displayName, .displayEmail {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.displayImg {
|
||||
display: inline-block;
|
||||
float: right;
|
||||
position: relative;
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
&.checked {
|
||||
z-index: 101;
|
||||
|
||||
.sidebarParent {
|
||||
background-color: #69A8F5;
|
||||
}
|
||||
}
|
||||
|
||||
&.selected {
|
||||
background-color: #fff;
|
||||
z-index: 102;
|
||||
|
||||
.sidebarParent {
|
||||
background-color: #398CF2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.b-view-content {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 60px;
|
||||
left: @contacts-popup-left-width;
|
||||
right: 0;
|
||||
overflow: hidden;
|
||||
overflow-y: auto;
|
||||
|
||||
background-color: #fff;
|
||||
border-left: 1px solid #ddd;
|
||||
|
||||
.content {
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.b-contact-view-desc {
|
||||
text-align: center;
|
||||
font-size: 24px;
|
||||
line-height: 30px;
|
||||
padding-top: 120px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.top-part {
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
.property-line {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.top-row {
|
||||
padding: 10px 0;
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
.add-link {
|
||||
padding-top: 5px;
|
||||
font-size: 12px;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.contactValueInput {
|
||||
|
||||
}
|
||||
|
||||
.hasError {
|
||||
.contactValueInput {
|
||||
color: #ee5f5b;
|
||||
border: 1px solid #ee5f5b;
|
||||
}
|
||||
}
|
||||
|
||||
.button-save-contact {
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.e-contact-item {
|
||||
|
||||
position: relative;
|
||||
height: 55px;
|
||||
max-height: 60px;
|
||||
line-height: 22px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
|
||||
margin: 0px;
|
||||
border: 0px solid transparent;
|
||||
z-index: 100;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ function MailBoxFolderListViewModel()
|
|||
|
||||
this.iDropOverTimer = 0;
|
||||
|
||||
this.allowContacts = !!RL.settingsGet('ContactsIsSupported') && !!RL.settingsGet('ContactsIsAllowed');
|
||||
this.allowContacts = !!RL.settingsGet('ContactsIsAllowed');
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('MailBoxFolderListViewModel', MailBoxFolderListViewModel);
|
||||
|
|
|
|||
|
|
@ -497,7 +497,7 @@ PopupsComposeViewModel.prototype.sendMessageResponse = function (sResult, oData)
|
|||
else
|
||||
{
|
||||
this.sendError(true);
|
||||
window.alert(Utils.getNotification(oData.ErrorCode ? oData.ErrorCode : Enums.Notification.CantSendMessage));
|
||||
window.alert(Utils.getNotification(oData && oData.ErrorCode ? oData.ErrorCode : Enums.Notification.CantSendMessage));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,12 +8,22 @@ function PopupsContactsViewModel()
|
|||
{
|
||||
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsContacts');
|
||||
|
||||
var self = this;
|
||||
var
|
||||
self = this,
|
||||
aNameTypes = [Enums.ContactPropertyType.FullName, Enums.ContactPropertyType.FirstName, Enums.ContactPropertyType.SurName, Enums.ContactPropertyType.MiddleName],
|
||||
aEmailTypes = [Enums.ContactPropertyType.EmailPersonal, Enums.ContactPropertyType.EmailBussines, Enums.ContactPropertyType.EmailOther],
|
||||
aPhonesTypes = [
|
||||
Enums.ContactPropertyType.PhonePersonal, Enums.ContactPropertyType.PhoneBussines, Enums.ContactPropertyType.PhoneOther,
|
||||
Enums.ContactPropertyType.MobilePersonal, Enums.ContactPropertyType.MobileBussines, Enums.ContactPropertyType.MobileOther,
|
||||
Enums.ContactPropertyType.FaxPesonal, Enums.ContactPropertyType.FaxBussines, Enums.ContactPropertyType.FaxOther
|
||||
],
|
||||
fFastClearEmptyListHelper = function (aList) {
|
||||
if (aList && 0 < aList.length) {
|
||||
self.viewProperties.removeAll(aList);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
this.imageUploader = ko.observable(null);
|
||||
this.imageDom = ko.observable(null);
|
||||
this.imageTrigger = ko.observable(false);
|
||||
|
||||
this.search = ko.observable('');
|
||||
this.contacts = ko.observableArray([]);
|
||||
this.contacts.loading = ko.observable(false).extend({'throttle': 200});
|
||||
|
|
@ -23,11 +33,50 @@ function PopupsContactsViewModel()
|
|||
this.viewClearSearch = ko.observable(false);
|
||||
|
||||
this.viewID = ko.observable('');
|
||||
this.viewName = ko.observable('');
|
||||
this.viewName.focused = ko.observable(false);
|
||||
this.viewEmail = ko.observable('').validateEmail();
|
||||
this.viewEmail.focused = ko.observable(false);
|
||||
this.viewImageUrl = ko.observable(RL.link().emptyContactPic());
|
||||
this.viewProperties = ko.observableArray([]);
|
||||
|
||||
this.viewPropertiesNames = this.viewProperties.filter(function(oProperty) {
|
||||
return -1 < Utils.inArray(oProperty.type(), aNameTypes);
|
||||
});
|
||||
|
||||
this.viewPropertiesEmails = this.viewProperties.filter(function(oProperty) {
|
||||
return -1 < Utils.inArray(oProperty.type(), aEmailTypes);
|
||||
});
|
||||
|
||||
this.viewHasNonEmptyRequaredProperties = ko.computed(function() {
|
||||
|
||||
var
|
||||
aNames = this.viewPropertiesNames(),
|
||||
aEmail = this.viewPropertiesEmails(),
|
||||
fHelper = function (oProperty) {
|
||||
return '' !== Utils.trim(oProperty.value());
|
||||
}
|
||||
;
|
||||
|
||||
return !!(_.find(aNames, fHelper) || _.find(aEmail, fHelper));
|
||||
}, this);
|
||||
|
||||
this.viewPropertiesPhones = this.viewProperties.filter(function(oProperty) {
|
||||
return -1 < Utils.inArray(oProperty.type(), aPhonesTypes);
|
||||
});
|
||||
|
||||
this.viewPropertiesEmailsEmptyAndOnFocused = this.viewPropertiesEmails.filter(function(oProperty) {
|
||||
var bF = oProperty.focused();
|
||||
return '' === Utils.trim(oProperty.value()) && !bF;
|
||||
});
|
||||
|
||||
this.viewPropertiesPhonesEmptyAndOnFocused = this.viewPropertiesPhones.filter(function(oProperty) {
|
||||
var bF = oProperty.focused();
|
||||
return '' === Utils.trim(oProperty.value()) && !bF;
|
||||
});
|
||||
|
||||
this.viewPropertiesEmailsEmptyAndOnFocused.subscribe(function(aList) {
|
||||
fFastClearEmptyListHelper(aList);
|
||||
});
|
||||
|
||||
this.viewPropertiesPhonesEmptyAndOnFocused.subscribe(function(aList) {
|
||||
fFastClearEmptyListHelper(aList);
|
||||
});
|
||||
|
||||
this.viewSaving = ko.observable(false);
|
||||
|
||||
|
|
@ -41,8 +90,8 @@ function PopupsContactsViewModel()
|
|||
Utils.windowResize();
|
||||
}, this);
|
||||
|
||||
this.viewImageUrl.subscribe(function (sUrl) {
|
||||
this.imageDom()['src'] = sUrl;
|
||||
this.viewProperties.subscribe(function () {
|
||||
Utils.windowResize();
|
||||
}, this);
|
||||
|
||||
this.contactsChecked = ko.computed(function () {
|
||||
|
|
@ -103,22 +152,26 @@ function PopupsContactsViewModel()
|
|||
if (Utils.isNonEmptyArray(aC))
|
||||
{
|
||||
aE = _.map(aC, function (oItem) {
|
||||
if (oItem && oItem['emails'])
|
||||
if (oItem)
|
||||
{
|
||||
var oEmail = new EmailModel(oItem['emails'][0] || '', oItem['name']);
|
||||
if (oEmail.validate())
|
||||
var
|
||||
aData = oItem.getNameAndEmailHelper(),
|
||||
oEmail = aData ? new EmailModel(aData[0], aData[1]) : null
|
||||
;
|
||||
|
||||
if (oEmail && oEmail.validate())
|
||||
{
|
||||
return oEmail;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
aE = _.compact(aE);
|
||||
}
|
||||
|
||||
if (Utils.isNonEmptyArray(aC))
|
||||
if (Utils.isNonEmptyArray(aE))
|
||||
{
|
||||
kn.hideScreenPopup(PopupsContactsViewModel);
|
||||
kn.showScreenPopup(PopupsComposeViewModel, [Enums.ComposeType.Empty, null, aE]);
|
||||
|
|
@ -133,12 +186,21 @@ function PopupsContactsViewModel()
|
|||
});
|
||||
|
||||
this.saveCommand = Utils.createCommand(this, function () {
|
||||
var
|
||||
|
||||
this.viewSaving(true);
|
||||
|
||||
var
|
||||
sRequestUid = Utils.fakeMd5(),
|
||||
bImageTrigger = this.imageTrigger()
|
||||
aProperties = []
|
||||
;
|
||||
|
||||
this.viewSaving(true);
|
||||
_.each(this.viewProperties(), function (oItem) {
|
||||
if (oItem.type() && '' !== Utils.trim(oItem.value()))
|
||||
{
|
||||
aProperties.push([oItem.type(), oItem.value()]);
|
||||
}
|
||||
});
|
||||
|
||||
RL.remote().contactSave(function (sResult, oData) {
|
||||
|
||||
self.viewSaving(false);
|
||||
|
|
@ -151,31 +213,42 @@ function PopupsContactsViewModel()
|
|||
}
|
||||
|
||||
self.reloadContactList();
|
||||
if (bImageTrigger)
|
||||
{
|
||||
RL.emailsPicsHashes();
|
||||
}
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// // TODO
|
||||
// }
|
||||
|
||||
}, sRequestUid, this.viewID(), this.viewName(), this.viewEmail(), bImageTrigger ? this.imageDom()['src'] : '');
|
||||
}, sRequestUid, this.viewID(), aProperties);
|
||||
|
||||
}, function () {
|
||||
var
|
||||
sViewName = this.viewName(),
|
||||
sViewEmail = this.viewEmail()
|
||||
;
|
||||
|
||||
return !this.viewSaving() &&
|
||||
('' !== sViewName || '' !== sViewEmail);
|
||||
var bV = this.viewHasNonEmptyRequaredProperties();
|
||||
return !this.viewSaving() && bV;
|
||||
});
|
||||
}
|
||||
|
||||
Utils.extendAsViewModel('PopupsContactsViewModel', PopupsContactsViewModel);
|
||||
|
||||
PopupsContactsViewModel.prototype.addNewEmail = function ()
|
||||
{
|
||||
// if (0 === this.viewPropertiesEmailsEmpty().length)
|
||||
// {
|
||||
var oItem = new ContactPropertyModel(Enums.ContactPropertyType.EmailPersonal, '');
|
||||
oItem.focused(true);
|
||||
this.viewProperties.push(oItem);
|
||||
// }
|
||||
};
|
||||
|
||||
PopupsContactsViewModel.prototype.addNewPhone = function ()
|
||||
{
|
||||
// if (0 === this.viewPropertiesPhonesEmpty().length)
|
||||
// {
|
||||
var oItem = new ContactPropertyModel(Enums.ContactPropertyType.PhonePersonal, '');
|
||||
oItem.focused(true);
|
||||
this.viewProperties.push(oItem);
|
||||
// }
|
||||
};
|
||||
|
||||
PopupsContactsViewModel.prototype.removeCheckedOrSelectedContactsFromList = function ()
|
||||
{
|
||||
var
|
||||
|
|
@ -241,28 +314,51 @@ PopupsContactsViewModel.prototype.deleteResponse = function (sResult, oData)
|
|||
}
|
||||
};
|
||||
|
||||
PopupsContactsViewModel.prototype.removeProperty = function (oProp)
|
||||
{
|
||||
this.viewProperties.remove(oProp);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?ContactModel} oContact
|
||||
*/
|
||||
PopupsContactsViewModel.prototype.populateViewContact = function (oContact)
|
||||
{
|
||||
this.imageTrigger(false);
|
||||
var
|
||||
sId = '',
|
||||
bHasName = false,
|
||||
aList = []
|
||||
;
|
||||
|
||||
this.emptySelection(false);
|
||||
|
||||
if (oContact)
|
||||
{
|
||||
this.viewID(oContact.idContact);
|
||||
this.viewName(oContact.name);
|
||||
this.viewEmail(oContact.emails[0] || '');
|
||||
this.viewImageUrl(oContact.srcAttr());
|
||||
sId = oContact.idContact;
|
||||
|
||||
if (Utils.isNonEmptyArray(oContact.properties))
|
||||
{
|
||||
_.each(oContact.properties, function (aProperty) {
|
||||
if (aProperty && aProperty[0])
|
||||
{
|
||||
aList.push(new ContactPropertyModel(aProperty[0], aProperty[1]));
|
||||
if (Enums.ContactPropertyType.FullName === aProperty[0])
|
||||
{
|
||||
bHasName = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (!bHasName)
|
||||
{
|
||||
this.viewID('');
|
||||
this.viewName('');
|
||||
this.viewEmail('');
|
||||
this.viewImageUrl(RL.link().emptyContactPic());
|
||||
aList.push(new ContactPropertyModel(Enums.ContactPropertyType.FullName, ''));
|
||||
}
|
||||
|
||||
this.viewID(sId);
|
||||
this.viewProperties([]);
|
||||
this.viewProperties(aList);
|
||||
};
|
||||
|
||||
PopupsContactsViewModel.prototype.reloadContactList = function ()
|
||||
|
|
@ -293,20 +389,16 @@ PopupsContactsViewModel.prototype.reloadContactList = function ()
|
|||
self.contacts.setSelectedByUid('' + self.viewID());
|
||||
}
|
||||
|
||||
}, this.search());
|
||||
}, 0, 20, this.search());
|
||||
};
|
||||
|
||||
PopupsContactsViewModel.prototype.onBuild = function (oDom)
|
||||
{
|
||||
this.initUploader();
|
||||
|
||||
this.oContentVisible = $('.b-list-content', oDom);
|
||||
this.oContentScrollable = $('.content', this.oContentVisible);
|
||||
|
||||
this.selector.init(this.oContentVisible, this.oContentScrollable);
|
||||
|
||||
this.viewImageUrl.valueHasMutated();
|
||||
|
||||
ko.computed(function () {
|
||||
var
|
||||
bModalVisibility = this.modalVisibility(),
|
||||
|
|
@ -316,56 +408,6 @@ PopupsContactsViewModel.prototype.onBuild = function (oDom)
|
|||
}, this).extend({'notify': 'always'});
|
||||
};
|
||||
|
||||
PopupsContactsViewModel.prototype.initUploader = function ()
|
||||
{
|
||||
var self = this, oJua = null;
|
||||
if (window.File && window.FileReader && this.imageUploader())
|
||||
{
|
||||
oJua = new Jua({
|
||||
'queueSize': 1,
|
||||
'multipleSizeLimit': 1,
|
||||
'clickElement': this.imageUploader(),
|
||||
'disableDragAndDrop': true,
|
||||
'disableMultiple': true,
|
||||
'onSelect': function (sId, oData) {
|
||||
|
||||
if (oData && oData['File'] && oData['File']['type'])
|
||||
{
|
||||
var
|
||||
oReader = null,
|
||||
oFile = oData['File'],
|
||||
sType = oData['File']['type']
|
||||
;
|
||||
|
||||
if (!sType.match(/image.*/))
|
||||
{
|
||||
window.alert('this file is not an image.');
|
||||
}
|
||||
else
|
||||
{
|
||||
oReader = new window.FileReader();
|
||||
oReader.onload = function (oEvent) {
|
||||
if (oEvent && oEvent.target && oEvent.target.result)
|
||||
{
|
||||
Utils.resizeAndCrop(oEvent.target.result, 150, function (sUrl) {
|
||||
self.viewImageUrl(sUrl);
|
||||
self.imageTrigger(true);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
oReader.readAsDataURL(oFile);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return oJua;
|
||||
};
|
||||
|
||||
PopupsContactsViewModel.prototype.onShow = function ()
|
||||
{
|
||||
kn.routeOff();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue