mirror of
http://git.whoc.org.uk/git/password-manager.git
synced 2025-01-10 06:50:03 +01:00
Updated MainController logic to keep the selected card listed, even when the filtering criteria does no longer match the selected card itself.
This commit is contained in:
parent
a891853d32
commit
c3add59d1b
@ -43,7 +43,10 @@ Clipperz.PM.UI.MainController = function() {
|
|||||||
this._isTouchDevice = ('ontouchstart' in window || 'onmsgesturechange' in window);
|
this._isTouchDevice = ('ontouchstart' in window || 'onmsgesturechange' in window);
|
||||||
this._isDesktop = window.screenX != 0 && !this._isTouchDevice;
|
this._isDesktop = window.screenX != 0 && !this._isTouchDevice;
|
||||||
this._hasKeyboard = this._isDesktop;
|
this._hasKeyboard = this._isDesktop;
|
||||||
|
|
||||||
|
this._cardInfoList = [];
|
||||||
|
this._selectedCardInfo = null;
|
||||||
|
|
||||||
this._closeMaskAction = null;
|
this._closeMaskAction = null;
|
||||||
|
|
||||||
this._pages = {};
|
this._pages = {};
|
||||||
@ -72,7 +75,7 @@ Clipperz.PM.UI.MainController = function() {
|
|||||||
'maskClick',
|
'maskClick',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
MochiKit.Signal.connect(MochiKit.DOM.currentDocument(), 'onselectionchange', this, 'selectionChangeHandler');
|
// MochiKit.Signal.connect(MochiKit.DOM.currentDocument(), 'onselectionchange', this, 'selectionChange_handler');
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -178,8 +181,8 @@ console.log("THE BROWSER IS OFFLINE");
|
|||||||
},
|
},
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
/*
|
||||||
selectionChangeHandler: function (anEvent) {
|
selectionChange_handler: function (anEvent) {
|
||||||
var selection;
|
var selection;
|
||||||
var selectionRange;
|
var selectionRange;
|
||||||
var selectionNode;
|
var selectionNode;
|
||||||
@ -214,7 +217,7 @@ console.log("THE BROWSER IS OFFLINE");
|
|||||||
}
|
}
|
||||||
//console.log("-----------");
|
//console.log("-----------");
|
||||||
},
|
},
|
||||||
|
*/
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
run: function (parameters) {
|
run: function (parameters) {
|
||||||
@ -509,19 +512,69 @@ console.log("SET USER", aUser);
|
|||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getRecordsInfo: function (cardInfo, shouldIncludeArchivedCards) {
|
||||||
|
return this.user().getRecordsInfo(Clipperz.PM.DataModel.Record.defaultCardInfo /*, shouldIncludeArchivedCards*/);
|
||||||
|
},
|
||||||
|
|
||||||
updateSelectedCards: function (shouldIncludeArchivedCards, aFilter) {
|
updateSelectedCards: function (shouldIncludeArchivedCards, aFilter) {
|
||||||
var deferredResult;
|
var deferredResult;
|
||||||
|
|
||||||
|
var filterCriteria;
|
||||||
var sortCriteria;
|
var sortCriteria;
|
||||||
|
var rangeFilter;
|
||||||
|
var fullFilterCriteria;
|
||||||
|
var selectedCardReference = this._selectedCardInfo ? this._selectedCardInfo['reference'] : null;
|
||||||
|
|
||||||
sortCriteria = Clipperz.Base.caseInsensitiveKeyComparator('label');
|
if (aFilter['type'] == 'ALL') {
|
||||||
|
filterCriteria = MochiKit.Base.operator.truth;
|
||||||
|
sortCriteria = Clipperz.Base.caseInsensitiveKeyComparator('label');
|
||||||
|
rangeFilter = MochiKit.Base.operator.identity;
|
||||||
|
} else if (aFilter['type'] == 'RECENT') {
|
||||||
|
filterCriteria = MochiKit.Base.operator.truth;
|
||||||
|
sortCriteria = Clipperz.Base.reverseComparator(MochiKit.Base.keyComparator('accessDate'));
|
||||||
|
rangeFilter = function (someCards) { return someCards.slice(0, 9)};
|
||||||
|
} else if (aFilter['type'] == 'SEARCH') {
|
||||||
|
filterCriteria = this.regExpFilterGenerator(Clipperz.PM.DataModel.Record.regExpForSearch(aFilter['value']));
|
||||||
|
sortCriteria = Clipperz.Base.caseInsensitiveKeyComparator('label');
|
||||||
|
rangeFilter = MochiKit.Base.operator.identity;
|
||||||
|
} else if (aFilter['type'] == 'TAG') {
|
||||||
|
filterCriteria = this.regExpFilterGenerator(Clipperz.PM.DataModel.Record.regExpForTag(aFilter['value']));
|
||||||
|
sortCriteria = Clipperz.Base.caseInsensitiveKeyComparator('label');
|
||||||
|
rangeFilter = MochiKit.Base.operator.identity;
|
||||||
|
} else if (aFilter['type'] == 'UNTAGGED') {
|
||||||
|
filterCriteria = this.regExpFilterGenerator(Clipperz.PM.DataModel.Record.regExpForNoTag());
|
||||||
|
sortCriteria = Clipperz.Base.caseInsensitiveKeyComparator('label');
|
||||||
|
rangeFilter = MochiKit.Base.operator.identity;
|
||||||
|
}
|
||||||
|
|
||||||
deferredResult = new Clipperz.Async.Deferred('MainController.setFilter', {trace:false});
|
fullFilterCriteria = function (aRecordInfo) {
|
||||||
deferredResult.addMethod(this.user(), 'getRecordsInfo', Clipperz.PM.DataModel.Record.defaultCardInfo, shouldIncludeArchivedCards);
|
var result;
|
||||||
|
|
||||||
|
if (aRecordInfo['_reference'] == selectedCardReference) {
|
||||||
|
result = true;
|
||||||
|
} else {
|
||||||
|
if ((shouldIncludeArchivedCards == false) && (aRecordInfo['_isArchived'])) {
|
||||||
|
result = false;
|
||||||
|
} else {
|
||||||
|
result = filterCriteria(aRecordInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
deferredResult = new Clipperz.Async.Deferred('MainController.updateSelectedCards', {trace:false});
|
||||||
|
deferredResult.addMethod(this, 'getRecordsInfo', Clipperz.PM.DataModel.Record.defaultCardInfo, shouldIncludeArchivedCards);
|
||||||
|
|
||||||
|
deferredResult.addCallback(MochiKit.Base.filter, fullFilterCriteria);
|
||||||
|
deferredResult.addMethodcaller('sort', sortCriteria);
|
||||||
|
deferredResult.addCallback(rangeFilter);
|
||||||
|
|
||||||
|
/*
|
||||||
if (aFilter['type'] == 'ALL') {
|
if (aFilter['type'] == 'ALL') {
|
||||||
deferredResult.addMethodcaller('sort', sortCriteria);
|
deferredResult.addMethodcaller('sort', sortCriteria);
|
||||||
} else if (aFilter['type'] == 'RECENT') {
|
} else if (aFilter['type'] == 'RECENT') {
|
||||||
deferredResult.addMethodcaller('sort', Clipperz.Base.reverseComparator(MochiKit.Base.keyComparator('accessDate')));
|
deferredResult.addMethodcaller('sort', sortCriteria);
|
||||||
deferredResult.addCallback(function (someCards) { return someCards.slice(0, 9)});
|
deferredResult.addCallback(function (someCards) { return someCards.slice(0, 9)});
|
||||||
} else if (aFilter['type'] == 'SEARCH') {
|
} else if (aFilter['type'] == 'SEARCH') {
|
||||||
deferredResult.addCallback(MochiKit.Base.filter, this.regExpFilterGenerator(Clipperz.PM.DataModel.Record.regExpForSearch(aFilter['value'])));
|
deferredResult.addCallback(MochiKit.Base.filter, this.regExpFilterGenerator(Clipperz.PM.DataModel.Record.regExpForSearch(aFilter['value'])));
|
||||||
@ -533,7 +586,7 @@ console.log("SET USER", aUser);
|
|||||||
deferredResult.addCallback(MochiKit.Base.filter, this.regExpFilterGenerator(Clipperz.PM.DataModel.Record.regExpForNoTag()));
|
deferredResult.addCallback(MochiKit.Base.filter, this.regExpFilterGenerator(Clipperz.PM.DataModel.Record.regExpForNoTag()));
|
||||||
deferredResult.addMethodcaller('sort', sortCriteria);
|
deferredResult.addMethodcaller('sort', sortCriteria);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
deferredResult.addMethod(this, 'setPageProperties', 'mainPage', 'cards');
|
deferredResult.addMethod(this, 'setPageProperties', 'mainPage', 'cards');
|
||||||
deferredResult.addCallback(MochiKit.Base.bind(function (someCards) {
|
deferredResult.addCallback(MochiKit.Base.bind(function (someCards) {
|
||||||
if (!this.isSelectedCardStillVisible(someCards)) {
|
if (!this.isSelectedCardStillVisible(someCards)) {
|
||||||
@ -935,7 +988,13 @@ console.log("SET USER", aUser);
|
|||||||
this.refreshCurrentPage();
|
this.refreshCurrentPage();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
resetCardSelection: function () {
|
||||||
|
this._selectedCardInfo = null;
|
||||||
|
},
|
||||||
|
|
||||||
cardSelected_handler: function (someInfo) {
|
cardSelected_handler: function (someInfo) {
|
||||||
|
this._selectedCardInfo = someInfo;
|
||||||
|
this.refreshSelectedCards();
|
||||||
this.updateSelectedCard(someInfo);
|
this.updateSelectedCard(someInfo);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1137,17 +1196,21 @@ console.log("SET USER", aUser);
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
selectAllCards_handler: function () {
|
selectAllCards_handler: function () {
|
||||||
|
this.resetCardSelection();
|
||||||
this.setFilter('ALL');
|
this.setFilter('ALL');
|
||||||
return this.refreshSelectedCards();
|
return this.refreshSelectedCards();
|
||||||
},
|
},
|
||||||
|
|
||||||
selectRecentCards_handler: function () {
|
selectRecentCards_handler: function () {
|
||||||
|
this.resetCardSelection();
|
||||||
this.setFilter('RECENT');
|
this.setFilter('RECENT');
|
||||||
return this.refreshSelectedCards();
|
return this.refreshSelectedCards();
|
||||||
},
|
},
|
||||||
|
|
||||||
search_handler: function (aValue) {
|
search_handler: function (aValue) {
|
||||||
//console.log("SEARCH", aValue);
|
//console.log("SEARCH", aValue);
|
||||||
|
this.resetCardSelection();
|
||||||
|
|
||||||
if (aValue == "") {
|
if (aValue == "") {
|
||||||
this.setFilter('ALL');
|
this.setFilter('ALL');
|
||||||
} else {
|
} else {
|
||||||
@ -1158,11 +1221,13 @@ console.log("SET USER", aUser);
|
|||||||
},
|
},
|
||||||
|
|
||||||
tagSelected_handler: function (aTag) {
|
tagSelected_handler: function (aTag) {
|
||||||
|
this.resetCardSelection();
|
||||||
this.setFilter('TAG', aTag);
|
this.setFilter('TAG', aTag);
|
||||||
return this.refreshSelectedCards();
|
return this.refreshSelectedCards();
|
||||||
},
|
},
|
||||||
|
|
||||||
selectUntaggedCards_handler: function () {
|
selectUntaggedCards_handler: function () {
|
||||||
|
this.resetCardSelection();
|
||||||
this.setFilter('UNTAGGED');
|
this.setFilter('UNTAGGED');
|
||||||
return this.refreshSelectedCards();
|
return this.refreshSelectedCards();
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user