Fixed an issue when editing a card label (without tags)
This commit is contained in:
parent
3c68167fb8
commit
3918a7bdfc
@ -21,12 +21,15 @@ refer to http://www.clipperz.com.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
"use strict";
|
||||||
try { if (typeof(Clipperz.KeyValueObjectStore) == 'undefined') { throw ""; }} catch (e) {
|
try { if (typeof(Clipperz.KeyValueObjectStore) == 'undefined') { throw ""; }} catch (e) {
|
||||||
throw "Clipperz.PM.DataModel.EncryptedRemoteObject depends on Clipperz.KeyValueObjectStore!";
|
throw "Clipperz.PM.DataModel.EncryptedRemoteObject depends on Clipperz.KeyValueObjectStore!";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
|
Clipperz.Base.module('Clipperz.PM.DataModel');
|
||||||
if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; }
|
|
||||||
|
//if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
|
||||||
|
//if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; }
|
||||||
|
|
||||||
Clipperz.PM.DataModel.EncryptedRemoteObject = function(args) {
|
Clipperz.PM.DataModel.EncryptedRemoteObject = function(args) {
|
||||||
args = args || {};
|
args = args || {};
|
||||||
|
@ -21,9 +21,12 @@ refer to http://www.clipperz.com.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
|
"use strict";
|
||||||
if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
|
Clipperz.Base.module('Clipperz.PM.DataModel');
|
||||||
if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; }
|
|
||||||
|
//if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
|
||||||
|
//if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
|
||||||
|
//if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; }
|
||||||
|
|
||||||
|
|
||||||
Clipperz.PM.DataModel.Record = function(args) {
|
Clipperz.PM.DataModel.Record = function(args) {
|
||||||
@ -142,14 +145,19 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.Encrypt
|
|||||||
'fullLabel': function () {
|
'fullLabel': function () {
|
||||||
return this.getIndexDataForKey('label');
|
return this.getIndexDataForKey('label');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'setFullLabel': function (aLabel, someTags) {
|
||||||
|
var fullLabel = MochiKit.Base.extend([aLabel], MochiKit.Base.map(function (aTag) { return Clipperz.PM.DataModel.Record.tagChar + aTag; }, someTags)).join(' ');
|
||||||
|
|
||||||
'updateFullLabelWithTags': function (someTags) {
|
return this.setIndexDataForKey('label', fullLabel);
|
||||||
return Clipperz.Async.callbacks("Record.updateFullLabelWithTags", [
|
},
|
||||||
|
|
||||||
|
'updateTags': function (someTagInfo) {
|
||||||
|
return Clipperz.Async.callbacks("Record.updateTags", [
|
||||||
MochiKit.Base.method(this, 'label'),
|
MochiKit.Base.method(this, 'label'),
|
||||||
function (aLabel) {
|
MochiKit.Base.bind(function (aLabel) {
|
||||||
return aLabel + ' ' + MochiKit.Base.map(function (aTag) { return Clipperz.PM.DataModel.Record.tagChar + aTag; }, MochiKit.Base.keys(someTags)).join(' ');
|
return this.setFullLabel(aLabel, MochiKit.Base.keys(someTagInfo));
|
||||||
},
|
}, this)
|
||||||
MochiKit.Base.method(this, 'setIndexDataForKey', 'label')
|
|
||||||
], {trace:false});
|
], {trace:false});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -183,7 +191,18 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.Encrypt
|
|||||||
},
|
},
|
||||||
|
|
||||||
'setLabel': function (aValue) {
|
'setLabel': function (aValue) {
|
||||||
return this.setIndexDataForKey('label', aValue); // [???]
|
// var tags;
|
||||||
|
|
||||||
|
return Clipperz.Async.callbacks("Record.setLabel", [
|
||||||
|
MochiKit.Base.method(this, 'tags'),
|
||||||
|
// function (someValues) { console.log("TAGS", someValues); tags = someValues; },
|
||||||
|
// MochiKit.Base.method(this, 'setIndexDataForKey', 'label', aValue),
|
||||||
|
// MochiKit.Base.method(this, 'updateFullLabelWithTags', tags),
|
||||||
|
MochiKit.Base.method(this, 'setFullLabel', aValue),
|
||||||
|
MochiKit.Base.method(this, 'label'),
|
||||||
|
], {trace:false});
|
||||||
|
|
||||||
|
// return this.setIndexDataForKey('label', aValue); // [???]
|
||||||
},
|
},
|
||||||
|
|
||||||
//.........................................................................
|
//.........................................................................
|
||||||
@ -217,7 +236,7 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.Encrypt
|
|||||||
MochiKit.Base.method(this, 'fullLabel'),
|
MochiKit.Base.method(this, 'fullLabel'),
|
||||||
MochiKit.Base.method(this, 'extractTags'),
|
MochiKit.Base.method(this, 'extractTags'),
|
||||||
function (someTags) { someTags[aNewTag] = true; /* console.log("UPDATED TAGS", someTags); */ return someTags; },
|
function (someTags) { someTags[aNewTag] = true; /* console.log("UPDATED TAGS", someTags); */ return someTags; },
|
||||||
MochiKit.Base.method(this, 'updateFullLabelWithTags')
|
MochiKit.Base.method(this, 'updateTags')
|
||||||
], {trace:false});
|
], {trace:false});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -227,7 +246,7 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.Encrypt
|
|||||||
MochiKit.Base.method(this, 'fullLabel'),
|
MochiKit.Base.method(this, 'fullLabel'),
|
||||||
MochiKit.Base.method(this, 'extractTags'),
|
MochiKit.Base.method(this, 'extractTags'),
|
||||||
function (someTags) { delete someTags[aTag]; return someTags; },
|
function (someTags) { delete someTags[aTag]; return someTags; },
|
||||||
MochiKit.Base.method(this, 'updateFullLabelWithTags')
|
MochiKit.Base.method(this, 'updateTags')
|
||||||
], {trace:false});
|
], {trace:false});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -754,7 +773,9 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.Encrypt
|
|||||||
'hasPendingChanges': function () {
|
'hasPendingChanges': function () {
|
||||||
var deferredResult;
|
var deferredResult;
|
||||||
|
|
||||||
if (this.hasInitiatedObjectDataStore()) {
|
/*if (this.isBrandNew()) {
|
||||||
|
deferredResult = MochiKit.Async.succeed(true);
|
||||||
|
} else*/ if (this.hasInitiatedObjectDataStore()) {
|
||||||
deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.hasPendingChanges", {trace:false});
|
deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.DataModel.Record.hasPendingChanges", {trace:false});
|
||||||
deferredResult.collectResults({
|
deferredResult.collectResults({
|
||||||
'super': MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.hasPendingChanges, this),
|
'super': MochiKit.Base.bind(Clipperz.PM.DataModel.Record.superclass.hasPendingChanges, this),
|
||||||
@ -984,6 +1005,14 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.Encrypt
|
|||||||
])
|
])
|
||||||
},
|
},
|
||||||
|
|
||||||
|
//=========================================================================
|
||||||
|
|
||||||
|
'setUpWithRecord': function (aRecord) {
|
||||||
|
return Clipperz.Async.callbacks("Record.hasAnyCleanTextData", [
|
||||||
|
MochiKit.Base.method(aRecord, 'full')
|
||||||
|
], {trace:false});
|
||||||
|
},
|
||||||
|
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
__syntaxFix__: "syntax fix"
|
__syntaxFix__: "syntax fix"
|
||||||
});
|
});
|
||||||
@ -995,6 +1024,7 @@ Clipperz.PM.DataModel.Record.defaultCardInfo = {
|
|||||||
'_searchableContent': MochiKit.Base.methodcaller('searchableContent'),
|
'_searchableContent': MochiKit.Base.methodcaller('searchableContent'),
|
||||||
'_accessDate': MochiKit.Base.methodcaller('accessDate'),
|
'_accessDate': MochiKit.Base.methodcaller('accessDate'),
|
||||||
'_isArchived': MochiKit.Base.methodcaller('isArchived'),
|
'_isArchived': MochiKit.Base.methodcaller('isArchived'),
|
||||||
|
'_isBrandNew': MochiKit.Base.methodcaller('isBrandNew'),
|
||||||
'label': MochiKit.Base.methodcaller('label'),
|
'label': MochiKit.Base.methodcaller('label'),
|
||||||
'favicon': MochiKit.Base.methodcaller('favicon')
|
'favicon': MochiKit.Base.methodcaller('favicon')
|
||||||
};
|
};
|
||||||
|
@ -21,9 +21,12 @@ refer to http://www.clipperz.com.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
|
"use strict";
|
||||||
if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
|
Clipperz.Base.module('Clipperz.PM.DataModel');
|
||||||
if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; }
|
|
||||||
|
//if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
|
||||||
|
//if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
|
||||||
|
//if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; }
|
||||||
|
|
||||||
|
|
||||||
//#############################################################################
|
//#############################################################################
|
||||||
@ -656,6 +659,14 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, {
|
|||||||
], {trace:false});
|
], {trace:false});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'cloneRecord': function (aRecord) {
|
||||||
|
console.log("USER.cloneRecord", aRecord);
|
||||||
|
return Clipperz.Async.callbacks("User.cloneRecord", [
|
||||||
|
MochiKit.Base.method(this, 'createNewRecord'),
|
||||||
|
MochiKit.Base.methodcaller('setUpWithRecord', aRecord)
|
||||||
|
], {trace:false});
|
||||||
|
},
|
||||||
|
|
||||||
//=========================================================================
|
//=========================================================================
|
||||||
|
|
||||||
'getDirectLogins': function() {
|
'getDirectLogins': function() {
|
||||||
|
@ -1514,6 +1514,10 @@ deferredResult.addCallback(function (aValue) { console.log("FIELDS", aValue); re
|
|||||||
deferredResult.addMethodcaller('tags');
|
deferredResult.addMethodcaller('tags');
|
||||||
deferredResult.addCallback(SimpleTest.eq, ['Tag1', 'Tag2']);
|
deferredResult.addCallback(SimpleTest.eq, ['Tag1', 'Tag2']);
|
||||||
|
|
||||||
|
deferredResult.addMethod(user, 'getRecord', recordID);
|
||||||
|
deferredResult.addMethodcaller('label');
|
||||||
|
deferredResult.addTest("Card 1", "expected label");
|
||||||
|
|
||||||
deferredResult.addMethod(user, 'getRecord', recordID);
|
deferredResult.addMethod(user, 'getRecord', recordID);
|
||||||
//deferredResult.addCallback(function (aValue) { console.log("VALUE", aValue); return aValue; });
|
//deferredResult.addCallback(function (aValue) { console.log("VALUE", aValue); return aValue; });
|
||||||
deferredResult.addMethodcaller('addTag', "TagX");
|
deferredResult.addMethodcaller('addTag', "TagX");
|
||||||
@ -1522,6 +1526,9 @@ deferredResult.addCallback(function (aValue) { console.log("FIELDS", aValue); re
|
|||||||
deferredResult.addMethodcaller('tags');
|
deferredResult.addMethodcaller('tags');
|
||||||
deferredResult.addCallback(SimpleTest.eq, ['Tag1', 'Tag2', 'TagX']);
|
deferredResult.addCallback(SimpleTest.eq, ['Tag1', 'Tag2', 'TagX']);
|
||||||
|
|
||||||
|
deferredResult.addMethod(user, 'getRecord', recordID);
|
||||||
|
deferredResult.addMethodcaller('setLabel', "Card 1 - edited");
|
||||||
|
|
||||||
deferredResult.addMethod(user, 'hasPendingChanges');
|
deferredResult.addMethod(user, 'hasPendingChanges');
|
||||||
deferredResult.addTest(true, "user should have pending changes");
|
deferredResult.addTest(true, "user should have pending changes");
|
||||||
deferredResult.addMethod(user, 'saveChanges');
|
deferredResult.addMethod(user, 'saveChanges');
|
||||||
|
@ -1397,10 +1397,14 @@ var tests = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
deferredResult.addMethod(user, 'createNewRecord');
|
deferredResult.addMethod(user, 'createNewRecord');
|
||||||
deferredResult.addMethodcaller('reference');
|
deferredResult.addMethodcaller('hasPendingChanges');
|
||||||
deferredResult.addCallback(function (aNewRecordReference) {
|
// deferredResult.addTest(true, "a brand new record should report pending changes until it is saved");
|
||||||
newRecordReference = aNewRecordReference;
|
deferredResult.addTest(false, "a brand new record should not report any pending changes until it is actually changed");
|
||||||
})
|
|
||||||
|
// deferredResult.addMethodcaller('reference');
|
||||||
|
// deferredResult.addCallback(function (aNewRecordReference) {
|
||||||
|
// newRecordReference = aNewRecordReference;
|
||||||
|
// })
|
||||||
|
|
||||||
deferredResult.addMethod(user, 'getRecords');
|
deferredResult.addMethod(user, 'getRecords');
|
||||||
deferredResult.addCallback(function (someRecords) {
|
deferredResult.addCallback(function (someRecords) {
|
||||||
|
Loading…
Reference in New Issue
Block a user