Remove tags support from code.

This commit is contained in:
RainLoop Team 2014-10-03 23:09:13 +04:00
parent 0a95b79eb2
commit 36bdce3084
15 changed files with 11 additions and 640 deletions

View file

@ -839,17 +839,6 @@
}, sQuery);
};
/**
* @param {string} sQuery
* @param {Function} fCallback
*/
AppApp.prototype.getContactTagsAutocomplete = function (sQuery, fCallback)
{
fCallback(_.filter(Data.contactTags(), function (oContactTag) {
return oContactTag && oContactTag.filterHelper(sQuery);
}));
};
AppApp.prototype.setMessageList = function (oData, bCached)
{
if (oData && oData.Result && 'Collection/MessageCollection' === oData.Result['@Object'] &&

74
dev/External/ko.js vendored
View file

@ -636,80 +636,6 @@
}
};
ko.bindingHandlers.contactTags = {
'init': function(oElement, fValueAccessor, fAllBindingsAccessor) {
var
Utils = require('Common/Utils'),
ContactTagModel = require('Model/ContactTag'),
$oEl = $(oElement),
fValue = fValueAccessor(),
fAllBindings = fAllBindingsAccessor(),
fAutoCompleteSource = fAllBindings['autoCompleteSource'] || null,
fFocusCallback = function (bValue) {
if (fValue && fValue.focusTrigger)
{
fValue.focusTrigger(bValue);
}
}
;
$oEl.inputosaurus({
'parseOnBlur': true,
'allowDragAndDrop': false,
'focusCallback': fFocusCallback,
'inputDelimiters': [',', ';'],
'outputDelimiter': ',',
'autoCompleteSource': fAutoCompleteSource,
'parseHook': function (aInput) {
return _.map(aInput, function (sInputValue) {
var
sValue = Utils.trim(sInputValue),
oTag = null
;
if ('' !== sValue)
{
oTag = new ContactTagModel();
oTag.name(sValue);
return [oTag.toLine(false), oTag];
}
return [sValue, null];
});
},
'change': _.bind(function (oEvent) {
$oEl.data('ContactTagsValue', oEvent.target.value);
fValue(oEvent.target.value);
}, this)
});
},
'update': function (oElement, fValueAccessor, fAllBindingsAccessor) {
var
$oEl = $(oElement),
fAllValueFunc = fAllBindingsAccessor(),
fContactTagsFilter = fAllValueFunc['contactTagsFilter'] || null,
sValue = ko.utils.unwrapObservable(fValueAccessor())
;
if ($oEl.data('ContactTagsValue') !== sValue)
{
$oEl.val(sValue);
$oEl.data('ContactTagsValue', sValue);
$oEl.inputosaurus('refresh');
}
if (fContactTagsFilter && ko.utils.unwrapObservable(fContactTagsFilter))
{
$oEl.inputosaurus('focus');
}
}
};
ko.bindingHandlers.command = {
'init': function (oElement, fValueAccessor, fAllBindingsAccessor, oViewModel) {
var

View file

@ -20,7 +20,6 @@
this.idContact = 0;
this.display = '';
this.properties = [];
this.tags = '';
this.readOnly = false;
this.focused = ko.observable(false);
@ -71,7 +70,6 @@
this.idContact = Utils.pInt(oItem['IdContact']);
this.display = Utils.pString(oItem['Display']);
this.readOnly = !!oItem['ReadOnly'];
this.tags = '';
if (Utils.isNonEmptyArray(oItem['Properties']))
{
@ -83,11 +81,6 @@
}, this);
}
if (Utils.isNonEmptyArray(oItem['Tags']))
{
this.tags = oItem['Tags'].join(',');
}
bResult = true;
}

View file

@ -1,58 +0,0 @@
(function () {
'use strict';
var
ko = require('ko'),
Utils = require('Common/Utils')
;
/**
* @constructor
*/
function ContactTagModel()
{
this.idContactTag = 0;
this.name = ko.observable('');
this.readOnly = false;
}
ContactTagModel.prototype.parse = function (oItem)
{
var bResult = false;
if (oItem && 'Object/Tag' === oItem['@Object'])
{
this.idContact = Utils.pInt(oItem['IdContactTag']);
this.name(Utils.pString(oItem['Name']));
this.readOnly = !!oItem['ReadOnly'];
bResult = true;
}
return bResult;
};
/**
* @param {string} sSearch
* @return {boolean}
*/
ContactTagModel.prototype.filterHelper = function (sSearch)
{
return this.name().toLowerCase().indexOf(sSearch.toLowerCase()) !== -1;
};
/**
* @param {boolean=} bEncodeHtml = false
* @return {string}
*/
ContactTagModel.prototype.toLine = function (bEncodeHtml)
{
return (Utils.isUnd(bEncodeHtml) ? false : !!bEncodeHtml) ?
Utils.encodeHtml(this.name()) : this.name();
};
module.exports = ContactTagModel;
}());

View file

@ -335,14 +335,6 @@
return true;
};
/**
* @return {string}
*/
EmailModel.prototype.inputoTagLine = function ()
{
return 0 < this.name.length ? this.name + ' (' + this.email + ')' : this.email;
};
module.exports = EmailModel;
}());

View file

@ -111,7 +111,6 @@
this.identitiesLoading = ko.observable(false).extend({'throttle': 100});
// contacts
this.contactTags = ko.observableArray([]);
this.contacts = ko.observableArray([]);
this.contacts.loading = ko.observable(false).extend({'throttle': 200});
this.contacts.importing = ko.observable(false).extend({'throttle': 200});

View file

@ -715,12 +715,11 @@
/**
* @param {?Function} fCallback
*/
RemoteAppStorage.prototype.contactSave = function (fCallback, sRequestUid, sUid, sTags, aProperties)
RemoteAppStorage.prototype.contactSave = function (fCallback, sRequestUid, sUid, aProperties)
{
this.defaultRequest(fCallback, 'ContactSave', {
'RequestUid': sRequestUid,
'Uid': Utils.trim(sUid),
'Tags': Utils.trim(sTags),
'Properties': aProperties
});
};

View file

@ -271,27 +271,6 @@
-webkit-overflow-scrolling: touch;
}
.tags-property-container {
font-size: 18px;
width: 400px;
.inputosaurus-container {
border-width: 1px;
border-color: transparent;
box-shadow: none;
&:hover {
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
border-color: #ccc;
}
&.inputosaurus-focused {
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
border-color: #999;
}
}
}
.contactValueStatic, .contactValueLargeStatic, .contactValueTextAreaStatic {
height: 20px;
line-height: 20px;

View file

@ -22,7 +22,6 @@
EmailModel = require('Model/Email'),
ContactModel = require('Model/Contact'),
ContactTagModel = require('Model/ContactTag'),
ContactPropertyModel = require('Model/ContactProperty'),
kn = require('Knoin/Knoin'),
@ -53,7 +52,6 @@
this.search = ko.observable('');
this.contactsCount = ko.observable(0);
this.contacts = Data.contacts;
this.contactTags = Data.contactTags;
this.currentContact = ko.observable(null);
@ -74,21 +72,6 @@
this.viewReadOnly = ko.observable(false);
this.viewProperties = ko.observableArray([]);
this.viewTags = ko.observable('');
this.viewTags.visibility = ko.observable(false);
this.viewTags.focusTrigger = ko.observable(false);
this.viewTags.focusTrigger.subscribe(function (bValue) {
if (!bValue && '' === this.viewTags())
{
this.viewTags.visibility(false);
}
else if (bValue)
{
this.viewTags.visibility(true);
}
}, this);
this.viewSaveTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.viewPropertiesNames = this.viewProperties.filter(function(oProperty) {
@ -336,7 +319,7 @@
}, 1000);
}
}, sRequestUid, this.viewID(), this.viewTags(), aProperties);
}, sRequestUid, this.viewID(), aProperties);
}, function () {
var
@ -369,7 +352,7 @@
this.watchHash = ko.observable(false);
this.viewHash = ko.computed(function () {
return '' + self.viewTags() + '|' + _.map(self.viewProperties(), function (oItem) {
return '' + _.map(self.viewProperties(), function (oItem) {
return oItem.value();
}).join('');
});
@ -385,23 +368,12 @@
this.sDefaultKeyScope = Enums.KeyState.ContactList;
this.contactTagsSource = _.bind(this.contactTagsSource, this);
kn.constructorEnd(this);
}
kn.extendAsViewModel(['View/Popup/Contacts', 'PopupsContactsViewModel'], ContactsPopupView);
_.extend(ContactsPopupView.prototype, AbstractView.prototype);
ContactsPopupView.prototype.contactTagsSource = function (oData, fResponse)
{
require('App/App').getContactTagsAutocomplete(oData.term, function (aData) {
fResponse(_.map(aData, function (oTagItem) {
return oTagItem.toLine(false);
}));
});
};
ContactsPopupView.prototype.getPropertyPlceholder = function (sType)
{
var sResult = '';
@ -442,12 +414,6 @@
}
};
ContactsPopupView.prototype.addNewTag = function ()
{
this.viewTags.visibility(true);
this.viewTags.focusTrigger(true);
};
ContactsPopupView.prototype.addNewEmail = function ()
{
this.addNewProperty(Enums.ContactPropertyType.Email, 'Home');
@ -621,7 +587,6 @@
this.emptySelection(false);
this.viewReadOnly(false);
this.viewTags('');
if (oContact)
{
@ -647,14 +612,9 @@
});
}
this.viewTags(oContact.tags);
this.viewReadOnly(!!oContact.readOnly);
}
this.viewTags.focusTrigger.valueHasMutated();
this.viewTags.visibility('' !== this.viewTags());
aList.unshift(new ContactPropertyModel(Enums.ContactPropertyType.LastName, '', sLastName, false,
this.getPropertyPlceholder(Enums.ContactPropertyType.LastName)));
@ -689,10 +649,10 @@
this.contacts.loading(true);
Remote.contacts(function (sResult, oData) {
var
iCount = 0,
aList = [],
aTagsList = []
aList = []
;
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.List)
@ -709,23 +669,12 @@
iCount = Utils.pInt(oData.Result.Count);
iCount = 0 < iCount ? iCount : 0;
}
if (Utils.isNonEmptyArray(oData.Result.Tags))
{
aTagsList = _.map(oData.Result.Tags, function (oItem) {
var oContactTag = new ContactTagModel();
return oContactTag.parse(oItem) ? oContactTag : null;
});
aTagsList = _.compact(aTagsList);
}
}
self.contactsCount(iCount);
self.contacts(aList);
self.contacts.loading(false);
self.contactTags(aTagsList);
self.viewClearSearch('' !== self.search());