Import contacts (close #44)

+ Some small improvements and fixes
This commit is contained in:
RainLoop Team 2014-01-15 00:02:30 +04:00
parent 9cc791caba
commit 8c0276631b
36 changed files with 628 additions and 66 deletions

View file

@ -58,6 +58,14 @@ LinkBuilder.prototype.upload = function ()
return this.sServer + '/Upload/' + this.sSpecSuffix + '/';
};
/**
* @return {string}
*/
LinkBuilder.prototype.uploadContacts = function ()
{
return this.sServer + '/UploadContacts/' + this.sSpecSuffix + '/';
};
/**
* @return {string}
*/

View file

@ -149,9 +149,16 @@ Selector.prototype.init = function (oContentVisible, oContentScrollable)
;
$(this.oContentVisible)
.on('selectstart', function (oEvent) {
if (oEvent && oEvent.preventDefault)
{
oEvent.preventDefault();
}
})
.on('click', this.sItemSelector, function (oEvent) {
self.actionClick(ko.dataFor(this), oEvent);
}).on('click', this.sItemCheckedSelector, function (oEvent) {
})
.on('click', this.sItemCheckedSelector, function (oEvent) {
var oItem = ko.dataFor(this);
if (oItem)
{

View file

@ -299,7 +299,7 @@
.box-shadow(none);
border-color: #fff;
font-size: 18px;
width: 250px;
width: 300px;
&:hover {
.box-shadow(inset 0 1px 1px rgba(0, 0, 0, 0.075));

View file

@ -1,11 +1,13 @@
.g-ui-user-select-none {
-webkit-user-select: none;
-webkit-touch-callout: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
-webkit-touch-callout: none;
standard-user-select: none;
}
.g-ui-clearfix {

View file

@ -13,7 +13,8 @@
line-height: 18px;
font-size: 18px;
margin-top: -2px;
margin-left: -2px;
margin-left: -1px;
width: 17px;
}
.iconsize24 {

View file

@ -32,8 +32,11 @@ function PopupsContactsViewModel()
this.contactsCount = ko.observable(0);
this.contacts = ko.observableArray([]);
this.contacts.loading = ko.observable(false).extend({'throttle': 200});
this.contacts.importing = ko.observable(false).extend({'throttle': 200});
this.currentContact = ko.observable(null);
this.importUploaderButton = ko.observable(null);
this.contactsSharingIsAllowed = !!RL.settingsGet('ContactsSharingIsAllowed');
this.contactsPage = ko.observable(1);
@ -336,6 +339,46 @@ PopupsContactsViewModel.prototype.addNewPhone = function ()
this.addNewProperty(Enums.ContactPropertyType.MobilePersonal);
};
PopupsContactsViewModel.prototype.initUploader = function ()
{
if (this.importUploaderButton())
{
var
oJua = new Jua({
'action': RL.link().uploadContacts(),
'name': 'uploader',
'queueSize': 1,
'multipleSizeLimit': 1,
'disableFolderDragAndDrop': true,
'disableDragAndDrop': true,
'disableMultiple': true,
'disableDocumentDropPrevent': true,
'clickElement': this.importUploaderButton()
})
;
if (oJua)
{
oJua
.on('onStart', _.bind(function () {
this.contacts.importing(true);
}, this))
.on('onComplete', _.bind(function (sId, bResult, oData) {
this.contacts.importing(false);
this.reloadContactList();
if (!sId || !bResult || !oData || !oData.Result)
{
window.alert(Utils.i18n('CONTACTS/ERROR_IMPORT_FILE'));
}
}, this))
;
}
}
};
PopupsContactsViewModel.prototype.removeCheckedOrSelectedContactsFromList = function ()
{
var
@ -575,6 +618,8 @@ PopupsContactsViewModel.prototype.onBuild = function (oDom)
return bResult;
});
this.initUploader();
};
PopupsContactsViewModel.prototype.onShow = function ()