Implementation of share contacts (begin)

This commit is contained in:
RainLoop Team 2013-12-18 20:05:30 +04:00
parent 5198dcfa20
commit 026839d864
17 changed files with 469 additions and 50 deletions

View file

@ -232,6 +232,20 @@ Enums.InterfaceAnimation = {
'Full': 'Full'
};
/**
* @enum {number}
*/
Enums.ContactScopeType = {
'Default': 0,
'Auto': 1,
'ShareAll': 2,
'ShareDomain': 3,
'ShareEmail': 4
};
/**
* @enum {number}
*/

View file

@ -8,10 +8,14 @@ function ContactModel()
this.idContact = 0;
this.display = '';
this.properties = [];
this.readOnly = false;
this.scopeType = Enums.ContactScopeType.Default;
this.scopeValue = '';
this.checked = ko.observable(false);
this.selected = ko.observable(false);
this.deleted = ko.observable(false);
this.shared = ko.observable(false);
}
/**
@ -55,6 +59,9 @@ ContactModel.prototype.parse = function (oItem)
{
this.idContact = Utils.pInt(oItem['IdContact']);
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']))
{
@ -65,6 +72,10 @@ ContactModel.prototype.parse = function (oItem)
}
}, this);
}
this.shared(-1 < Utils.inArray(this.scopeType, [
Enums.ContactScopeType.ShareAll, Enums.ContactScopeType.ShareDomain, Enums.ContactScopeType.ShareEmail
]));
bResult = true;
}
@ -106,6 +117,10 @@ ContactModel.prototype.lineAsCcc = function ()
{
aResult.push('checked');
}
if (this.shared())
{
aResult.push('shared');
}
return aResult.join(' ');
};

View file

@ -171,6 +171,13 @@
float: left;
padding: 0 8px 0 6px;
}
.shareParent {
display: none;
float: right;
position: relative;
margin: 2px 8px 0 5px;
}
.nameParent {
display: block;
@ -196,6 +203,10 @@
margin: 0 5px;
}
&.shared .shareParent {
display: inline-block;
}
&.checked {
z-index: 101;
@ -231,6 +242,26 @@
-webkit-overflow-scrolling: touch;
}
.contactValueStatic {
height: 20px;
line-height: 20px;
font-size: 18px;
display: inline-block;
padding: 5px 7px;
color: #555;
display: none;
}
&.read-only {
.contactValueStatic {
display: inline-block;
}
.contactValueInput {
display: none;
}
}
.b-contact-view-desc {
text-align: center;
font-size: 24px;
@ -254,26 +285,73 @@
.add-link {
padding-top: 5px;
padding-left: 7px;
font-size: 12px;
color: #aaa;
}
.contactValueStatic {
font-size: 18px;
display: none;
}
.contactValueInput {
.box-shadow(none);
border-color: #fff;
font-size: 18px;
width: 250px;
&:hover {
.box-shadow(inset 0 1px 1px rgba(0, 0, 0, 0.075));
border-color: #ccc;
}
&:focus {
.box-shadow(inset 0 1px 1px rgba(0, 0, 0, 0.075));
border-color: #999;
}
}
.hasError {
.contactValueInput {
color: #ee5f5b;
border: 1px solid #ee5f5b;
border-color: #ee5f5b;
}
}
.e-read-only-sign {
display: none;
position: absolute;
top: 20px;
right: 40px;
}
.e-share-sign {
position: absolute;
top: 60px;
right: 20px;
cursor: pointer;
}
.button-save-contact {
position: absolute;
top: 20px;
right: 20px;
}
&.read-only {
.e-read-only-sign {
display: inline-block;
}
.e-share-sign {
display: none;
}
.button-save-contact {
display: none;
}
}
}
}

View file

@ -46,6 +46,9 @@ function PopupsContactsViewModel()
this.viewClearSearch = ko.observable(false);
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.viewPropertiesNames = this.viewProperties.filter(function(oProperty) {
@ -56,6 +59,24 @@ function PopupsContactsViewModel()
return -1 < Utils.inArray(oProperty.type(), aEmailTypes);
});
this.shareToNone = ko.computed(function() {
return -1 === Utils.inArray(this.viewScopeType(), [
Enums.ContactScopeType.ShareAll, Enums.ContactScopeType.ShareDomain, Enums.ContactScopeType.ShareEmail
]);
}, 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
@ -236,8 +257,11 @@ function PopupsContactsViewModel()
}, sRequestUid, this.viewID(), aProperties);
}, function () {
var bV = this.viewHasNonEmptyRequaredProperties();
return !this.viewSaving() && bV;
var
bV = this.viewHasNonEmptyRequaredProperties(),
bReadOnly = this.viewReadOnly()
;
return !this.viewSaving() && bV && !bReadOnly;
});
this.bDropPageAfterDelete = false;
@ -354,6 +378,9 @@ PopupsContactsViewModel.prototype.populateViewContact = function (oContact)
;
this.emptySelection(false);
this.viewReadOnly(false);
this.viewScopeType(Enums.ContactScopeType.Default);
this.viewScopeValue('');
if (oContact)
{
@ -372,6 +399,10 @@ PopupsContactsViewModel.prototype.populateViewContact = function (oContact)
}
});
}
this.viewReadOnly(!!oContact.readOnly);
this.viewScopeType(oContact.scopeType);
this.viewScopeValue(oContact.scopeValue);
}
if (!bHasName)