Added very first rough prototype of tag editor
This commit is contained in:
parent
5b8da33360
commit
f42c469663
@ -27,12 +27,13 @@ Clipperz.PM.UI.Components.Cards.Detail = React.createClass({
|
|||||||
|
|
||||||
viewComponentProps: function () {
|
viewComponentProps: function () {
|
||||||
var result;
|
var result;
|
||||||
|
|
||||||
result = this.props['selectedCard'];
|
result = this.props['selectedCard'];
|
||||||
if (result) {
|
if (result) {
|
||||||
result['style'] = this.props['style'];
|
result['style'] = this.props['style'];
|
||||||
result['ask'] = (this.props['style'] == 'narrow') ? this.props['ask'] : null;
|
result['ask'] = (this.props['style'] == 'narrow') ? this.props['ask'] : null;
|
||||||
result['showGlobalMask'] = this.props['showGlobalMask'];
|
result['showGlobalMask'] = this.props['showGlobalMask'];
|
||||||
|
result['allTags'] = this.props['allTags'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -243,15 +243,13 @@ console.log("DROP"); //, anEvent);
|
|||||||
|
|
||||||
//............................................................................
|
//............................................................................
|
||||||
|
|
||||||
renderTag: function (aTag) {
|
|
||||||
return React.DOM.div({'className':'cardTag'}, aTag);
|
|
||||||
},
|
|
||||||
|
|
||||||
renderTags: function (someTags) {
|
renderTags: function (someTags) {
|
||||||
var tags;
|
var tags;
|
||||||
|
var allTags;
|
||||||
|
|
||||||
tags = MochiKit.Base.filter(Clipperz.PM.DataModel.Record.isRegularTag, someTags).sort(Clipperz.Base.caseInsensitiveCompare);
|
tags = MochiKit.Base.filter(Clipperz.PM.DataModel.Record.isRegularTag, someTags).sort(Clipperz.Base.caseInsensitiveCompare);
|
||||||
return React.DOM.div({'className':'cardTags'}, MochiKit.Base.map(this.renderTag, tags));
|
allTags = tags;
|
||||||
|
return Clipperz.PM.UI.Components.Cards.TagEditor({'selectedTags':tags, 'allTags':allTags, 'readOnly':false });
|
||||||
},
|
},
|
||||||
|
|
||||||
//............................................................................
|
//............................................................................
|
||||||
|
142
frontend/delta/js/Clipperz/PM/UI/Components/Cards/TagEditor.js
Normal file
142
frontend/delta/js/Clipperz/PM/UI/Components/Cards/TagEditor.js
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Copyright 2008-2013 Clipperz Srl
|
||||||
|
|
||||||
|
This file is part of Clipperz, the online password manager.
|
||||||
|
For further information about its features and functionalities please
|
||||||
|
refer to http://www.clipperz.com.
|
||||||
|
|
||||||
|
* Clipperz is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU Affero General Public License as published
|
||||||
|
by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
* Clipperz is distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
* You should have received a copy of the GNU Affero General Public
|
||||||
|
License along with Clipperz. If not, see http://www.gnu.org/licenses/.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
Clipperz.Base.module('Clipperz.PM.UI.Components.Cards');
|
||||||
|
|
||||||
|
Clipperz.PM.UI.Components.Cards.TagEditor = React.createClass({
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
|
||||||
|
propTypes: {
|
||||||
|
'allTags': React.PropTypes.array,
|
||||||
|
'selectedTags': React.PropTypes.array.isRequired,
|
||||||
|
'readOnly': React.PropTypes.bool.isRequired,
|
||||||
|
'updateTagsCallback': React.PropTypes.func,
|
||||||
|
},
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
isReadOnly: function () {
|
||||||
|
return this.props['readOnly'];
|
||||||
|
},
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
stillNotUsedTags: function () {
|
||||||
|
// return MochiKit.Base.filter(function, this.props['allTags']);
|
||||||
|
},
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
removeTagHandler: function (anEvent) {
|
||||||
|
this.removeTag(anEvent.currentTarget.dataset['label']);
|
||||||
|
},
|
||||||
|
|
||||||
|
addTag: function (aTag) {
|
||||||
|
//console.log("ADD TAG", aTag);
|
||||||
|
// TODO: here we may need to include the record or its reference to let the MainController handle it properly.
|
||||||
|
MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'addTag', aTag);
|
||||||
|
},
|
||||||
|
|
||||||
|
removeTag: function (aTag) {
|
||||||
|
//console.log("REMOVE TAG", aTag);
|
||||||
|
// TODO: here we may need to include the record or its reference to let the MainController handle it properly.
|
||||||
|
MochiKit.Signal.signal(Clipperz.Signal.NotificationCenter, 'removeTag', aTag);
|
||||||
|
},
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
handleKeyDown: function(anEvent) {
|
||||||
|
switch (anEvent.keyCode) {
|
||||||
|
|
||||||
|
case 9: // tab
|
||||||
|
console.log("TAB");
|
||||||
|
// if (anEvent.shiftKey || !this.state.isOpen) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// this.selectFocusedOption();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 13: // enter
|
||||||
|
console.log("ENTER");
|
||||||
|
this.addTag(anEvent.currentTarget.value);
|
||||||
|
anEvent.currentTarget.value = "";
|
||||||
|
// this.selectFocusedOption();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 27: // escape
|
||||||
|
console.log("ESCAPE");
|
||||||
|
// if (this.state.isOpen) {
|
||||||
|
// this.closeOnEscape();
|
||||||
|
// } else {
|
||||||
|
// this.clearValue();
|
||||||
|
// }
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 38: // up
|
||||||
|
console.log("UP");
|
||||||
|
// this.focusPreviousOption();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 40: // down
|
||||||
|
console.log("DOWN");
|
||||||
|
// this.focusNextOption();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: return;
|
||||||
|
}
|
||||||
|
|
||||||
|
anEvent.preventDefault();
|
||||||
|
},
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
renderTag: function (aTag) {
|
||||||
|
return React.DOM.li({'className':'tag'}, [
|
||||||
|
React.DOM.span({'className':'tagLabel'}, aTag),
|
||||||
|
this.isReadOnly() ? null : React.DOM.span({'className':'tagRemoveButton', 'onClick':this.removeTagHandler, 'data-label':aTag}, 'delete')
|
||||||
|
])
|
||||||
|
},
|
||||||
|
|
||||||
|
renderEditField: function () {
|
||||||
|
return React.DOM.input({'type':'text', 'onKeyDown': this.handleKeyDown});
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function () {
|
||||||
|
var classes = {
|
||||||
|
'tagEditor': true,
|
||||||
|
'readOnly': this.props['readOnly'],
|
||||||
|
'readWrite': !this.props['readOnly']
|
||||||
|
};
|
||||||
|
|
||||||
|
return React.DOM.div({'className':React.addons.classSet(classes)}, [
|
||||||
|
React.DOM.ul({},[
|
||||||
|
MochiKit.Base.map(this.renderTag, this.props['selectedTags']),
|
||||||
|
this.isReadOnly() ? null : this.renderEditField()
|
||||||
|
])
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
|
||||||
|
//=========================================================================
|
||||||
|
});
|
@ -78,15 +78,16 @@ Clipperz.PM.UI.Components.Cards.View = React.createClass({
|
|||||||
|
|
||||||
//............................................................................
|
//............................................................................
|
||||||
|
|
||||||
renderTag: function (aTag) {
|
// renderTag: function (aTag) {
|
||||||
return React.DOM.div({'className':'cardTag'}, aTag);
|
// return React.DOM.div({'className':'cardTag'}, aTag);
|
||||||
},
|
// },
|
||||||
|
|
||||||
renderTags: function (someTags) {
|
renderTags: function (someTags) {
|
||||||
var tags;
|
var tags;
|
||||||
|
|
||||||
tags = MochiKit.Base.filter(Clipperz.PM.DataModel.Record.isRegularTag, someTags).sort(Clipperz.Base.caseInsensitiveCompare);
|
tags = MochiKit.Base.filter(Clipperz.PM.DataModel.Record.isRegularTag, someTags).sort(Clipperz.Base.caseInsensitiveCompare);
|
||||||
return React.DOM.div({'className':'cardTags'}, MochiKit.Base.map(this.renderTag, tags));
|
// return React.DOM.div({'className':'cardTags'}, MochiKit.Base.map(this.renderTag, tags));
|
||||||
|
return Clipperz.PM.UI.Components.Cards.TagEditor({'selectedTags':tags, 'readOnly':true });
|
||||||
},
|
},
|
||||||
|
|
||||||
//............................................................................
|
//............................................................................
|
||||||
|
@ -56,38 +56,18 @@ Clipperz.PM.UI.MainController = function() {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
this.registerForNotificationCenterEvents([
|
this.registerForNotificationCenterEvents([
|
||||||
'doLogin',
|
'doLogin', 'registerNewUser', 'showRegistrationForm', 'goBack',
|
||||||
'registerNewUser',
|
'toggleSelectionPanel', 'toggleSettingsPanel',
|
||||||
'showRegistrationForm',
|
'matchMediaQuery', 'unmatchMediaQuery',
|
||||||
'goBack',
|
'selectAllCards', 'selectRecentCards', 'tagSelected', 'selectUntaggedCards',
|
||||||
|
|
||||||
'toggleSelectionPanel',
|
|
||||||
'toggleSettingsPanel',
|
|
||||||
|
|
||||||
'matchMediaQuery',
|
|
||||||
'unmatchMediaQuery',
|
|
||||||
|
|
||||||
'selectAllCards',
|
|
||||||
'selectRecentCards',
|
|
||||||
'tagSelected',
|
|
||||||
'selectUntaggedCards',
|
|
||||||
|
|
||||||
'refreshCardEditDetail',
|
'refreshCardEditDetail',
|
||||||
// 'refreshCardEditToolbar',
|
// 'refreshCardEditToolbar',
|
||||||
'saveCardEdits',
|
'saveCardEdits', 'cancelCardEdits',
|
||||||
'cancelCardEdits',
|
|
||||||
|
|
||||||
'cardSelected',
|
'cardSelected',
|
||||||
|
|
||||||
'addCardClick',
|
'addCardClick',
|
||||||
'deleteCard',
|
'deleteCard', 'archiveCard', 'cloneCard', 'editCard',
|
||||||
'archiveCard',
|
'addTag', 'removeTag',
|
||||||
'cloneCard',
|
'showArchivedCards', 'hideArchivedCards',
|
||||||
'editCard',
|
|
||||||
|
|
||||||
'showArchivedCards',
|
|
||||||
'hideArchivedCards',
|
|
||||||
|
|
||||||
'goBackToMainPage',
|
'goBackToMainPage',
|
||||||
'maskClick',
|
'maskClick',
|
||||||
]);
|
]);
|
||||||
@ -626,9 +606,14 @@ console.log("SET USER", aUser);
|
|||||||
return aValue;
|
return aValue;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
allTags: function (shouldIncludeArchivedCards) {
|
||||||
|
return this.user().getTags(shouldIncludeArchivedCards);
|
||||||
|
},
|
||||||
|
|
||||||
renderTags: function () {
|
renderTags: function () {
|
||||||
return Clipperz.Async.callbacks("MainController.renderTags", [
|
return Clipperz.Async.callbacks("MainController.renderTags", [
|
||||||
MochiKit.Base.method(this.user(), 'getTags', this.shouldIncludeArchivedCards()),
|
// MochiKit.Base.method(this.user(), 'getTags', this.shouldIncludeArchivedCards()),
|
||||||
|
MochiKit.Base.method(this, 'allTags', this.shouldIncludeArchivedCards()),
|
||||||
MochiKit.Base.method(this, 'setPageProperties', 'mainPage', 'tags'),
|
MochiKit.Base.method(this, 'setPageProperties', 'mainPage', 'tags'),
|
||||||
MochiKit.Base.method(this, 'getArchivedCardsCount'),
|
MochiKit.Base.method(this, 'getArchivedCardsCount'),
|
||||||
MochiKit.Base.method(this, 'setPageProperties', 'mainPage', 'archivedCardsCount'),
|
MochiKit.Base.method(this, 'setPageProperties', 'mainPage', 'archivedCardsCount'),
|
||||||
@ -1046,9 +1031,10 @@ console.log("SET USER", aUser);
|
|||||||
MochiKit.Base.method(this.user(), 'createNewRecord'),
|
MochiKit.Base.method(this.user(), 'createNewRecord'),
|
||||||
MochiKit.Base.methodcaller('reference'),
|
MochiKit.Base.methodcaller('reference'),
|
||||||
MochiKit.Base.method(this, 'refreshUI'),
|
MochiKit.Base.method(this, 'refreshUI'),
|
||||||
MochiKit.Base.bind(function () {
|
// MochiKit.Base.bind(function () {
|
||||||
this.pages()[this.currentPage()].setProps({'mode': 'edit'});
|
// this.pages()[this.currentPage()].setProps({'mode': 'edit'});
|
||||||
}, this),
|
// }, this),
|
||||||
|
MochiKit.Base.method(this, 'enterEditMode'),
|
||||||
], {trace:false});
|
], {trace:false});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1092,9 +1078,55 @@ console.log("SET USER", aUser);
|
|||||||
], {trace:false});
|
], {trace:false});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
enterEditMode: function () {
|
||||||
|
var currentPage = this.pages()[this.currentPage()];
|
||||||
|
|
||||||
|
currentPage.setProps({'mode': 'edit'});
|
||||||
|
|
||||||
|
return Clipperz.Async.callbacks("MainController.enterEditMode", [
|
||||||
|
MochiKit.Base.method(this, 'allTags', true),
|
||||||
|
MochiKit.Base.keys,
|
||||||
|
function (aValue) {
|
||||||
|
currentPage.setProps({'allTags': aValue});
|
||||||
|
},
|
||||||
|
], {trace:false});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
editCard_handler: function (anEvent) {
|
editCard_handler: function (anEvent) {
|
||||||
//console.log("EDIT CARD", anEvent['reference']);
|
//console.log("EDIT CARD", anEvent['reference']);
|
||||||
this.pages()[this.currentPage()].setProps({'mode': 'edit'});
|
// this.pages()[this.currentPage()].setProps({'mode': 'edit'});
|
||||||
|
this.enterEditMode();
|
||||||
|
},
|
||||||
|
|
||||||
|
addTag_handler: function (anEvent) {
|
||||||
|
var record = this.pages()[this.currentPage()].props['selectedCard']['_record'];
|
||||||
|
var tag = anEvent;
|
||||||
|
var deferredResult;
|
||||||
|
|
||||||
|
deferredResult = new Clipperz.Async.Deferred('MainController.addTag', {trace:false});
|
||||||
|
deferredResult.addMethod(record, 'addTag', tag);
|
||||||
|
deferredResult.addMethod(this, 'collectRecordInfo', record);
|
||||||
|
deferredResult.addMethod(this, 'setPageProperties', this.currentPage(), 'selectedCard');
|
||||||
|
// deferredResult.addMethod(this, 'refreshCurrentPage');
|
||||||
|
deferredResult.callback();
|
||||||
|
|
||||||
|
return deferredResult;
|
||||||
|
},
|
||||||
|
|
||||||
|
removeTag_handler: function (anEvent) {
|
||||||
|
var record = this.pages()[this.currentPage()].props['selectedCard']['_record'];
|
||||||
|
var tag = anEvent;
|
||||||
|
var deferredResult;
|
||||||
|
|
||||||
|
deferredResult = new Clipperz.Async.Deferred('MainController.removeTag', {trace:false});
|
||||||
|
deferredResult.addMethod(record, 'removeTag', tag);
|
||||||
|
deferredResult.addMethod(this, 'collectRecordInfo', record);
|
||||||
|
deferredResult.addMethod(this, 'setPageProperties', this.currentPage(), 'selectedCard');
|
||||||
|
// deferredResult.addMethod(this, 'refreshCurrentPage');
|
||||||
|
deferredResult.callback();
|
||||||
|
|
||||||
|
return deferredResult;
|
||||||
},
|
},
|
||||||
|
|
||||||
goBackToMainPage_handler: function (anEvent) {
|
goBackToMainPage_handler: function (anEvent) {
|
||||||
|
@ -159,6 +159,7 @@
|
|||||||
"Clipperz/PM/UI/Components/Cards/Edit.js",
|
"Clipperz/PM/UI/Components/Cards/Edit.js",
|
||||||
"Clipperz/PM/UI/Components/Cards/CommandToolbar.js",
|
"Clipperz/PM/UI/Components/Cards/CommandToolbar.js",
|
||||||
"Clipperz/PM/UI/Components/Cards/EditToolbar.js",
|
"Clipperz/PM/UI/Components/Cards/EditToolbar.js",
|
||||||
|
"Clipperz/PM/UI/Components/Cards/TagEditor.js",
|
||||||
|
|
||||||
"Clipperz/PM/UI/Components/AccountStatus.js",
|
"Clipperz/PM/UI/Components/AccountStatus.js",
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
@import "core/overlay";
|
@import "core/overlay";
|
||||||
@import "core/behavior";
|
@import "core/behavior";
|
||||||
@import "core/layout";
|
@import "core/layout";
|
||||||
|
@import "core/tagEditor";
|
||||||
|
|
||||||
@import "style/loadingPage";
|
@import "style/loadingPage";
|
||||||
@import "style/loginPage";
|
@import "style/loginPage";
|
||||||
|
File diff suppressed because one or more lines are too long
31
frontend/delta/scss/core/tagEditor.scss
Normal file
31
frontend/delta/scss/core/tagEditor.scss
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
.tagEditor {
|
||||||
|
|
||||||
|
&.readWrite {
|
||||||
|
border: 1px solid red;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul {
|
||||||
|
@include flexbox();
|
||||||
|
@include flex-direction(row);
|
||||||
|
@include align-items(flex-start);
|
||||||
|
|
||||||
|
li.tag {
|
||||||
|
@include flex(none);
|
||||||
|
font-size: 14pt;
|
||||||
|
padding-right: 10px;
|
||||||
|
|
||||||
|
&:before {
|
||||||
|
content: 'tag';
|
||||||
|
@include icon-font();
|
||||||
|
font-size: 10pt;
|
||||||
|
padding-right: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
span.tagRemoveButton {
|
||||||
|
@include icon-font();
|
||||||
|
color: gray;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -224,27 +224,10 @@ $cardViewBasePadding: 10px;
|
|||||||
padding: $cardViewBasePadding;
|
padding: $cardViewBasePadding;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cardTags {
|
.tagEditor {
|
||||||
@include flexbox();
|
|
||||||
@include flex-direction(row);
|
|
||||||
@include align-items(flex-start);
|
|
||||||
|
|
||||||
padding: $cardViewBasePadding;
|
padding: $cardViewBasePadding;
|
||||||
|
|
||||||
.cardTag {
|
|
||||||
@include flex(none);
|
|
||||||
font-size: 14pt;
|
|
||||||
padding-right: 10px;
|
|
||||||
|
|
||||||
&:before {
|
|
||||||
content: 'tag';
|
|
||||||
@include icon-font();
|
|
||||||
font-size: 10pt;
|
|
||||||
padding-right: 4px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.cardNotes {
|
.cardNotes {
|
||||||
padding: $cardViewBasePadding;
|
padding: $cardViewBasePadding;
|
||||||
}
|
}
|
||||||
@ -281,7 +264,9 @@ $cardViewBasePadding: 10px;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.removeField {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.fieldAction {
|
.fieldAction {
|
||||||
@ -298,6 +283,10 @@ $cardViewBasePadding: 10px;
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.newCardField {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.cardDirectLogin {
|
.cardDirectLogin {
|
||||||
font-size: 18pt;
|
font-size: 18pt;
|
||||||
padding: $cardViewBasePadding;
|
padding: $cardViewBasePadding;
|
||||||
|
Loading…
Reference in New Issue
Block a user