1
0
mirror of http://git.whoc.org.uk/git/password-manager.git synced 2025-10-24 01:07:35 +02:00

Fixed UI behavior on window resize, fixed Attachment UI in card View

This commit is contained in:
Dario Chiappetta
2015-11-26 10:09:52 +01:00
parent 0abd559e81
commit db47e5b7fb
14 changed files with 120 additions and 53 deletions

View File

@@ -493,14 +493,18 @@ Clipperz.log(">>> Connection.messageExceptionHandler: " + anError.message, anEr
if (anError instanceof MochiKit.Async.CancelledError) {
result = anError;
} else {
if ((anError.message == 'Trying to communicate without an active connection') ||
(anError.message == 'No tollManager available for current session')
var errorPayload;
errorPayload = Clipperz.Base.evalJSON(anError.req.responseText);
if ((errorPayload.message == 'Trying to communicate without an active connection') ||
(errorPayload.message == 'No tollManager available for current session') ||
(errorPayload.message == 'HashCash verification failed. The provided toll is not valid.')
) {
result = this.reestablishConnection(anOriginalMessageArguments);
} else if (anError.message == 'Session with stale data') {
} else if (errorPayload.message == 'Session with stale data') {
MochiKit.Signal.signal(this, 'EXCEPTION');
} else {
result = anError;
result = errorPayload;
}
}
Clipperz.log("<<< Connection.messageExceptionHandler")

View File

@@ -42,7 +42,7 @@ Clipperz.PM.DataModel.Record = function(args) {
this._setDirectLoginIndexDataFunction = args.setDirectLoginIndexDataFunction || null;
this._removeDirectLoginIndexDataFunction = args.removeDirectLoginIndexDataFunction || null;
this._createNewDirectLoginFunction = args.createNewDirectLoginFunction || null;
this._retrieveAttachmentIndexDataFunction = args.retrieveAttachmentIndexDataFunction || null;
this._setAttachmentIndexDataFunction = args.setAttachmentIndexDataFunction || null;
this._removeAttachmentIndexDataFunction = args.removeAttachmentIndexDataFunction || null;
@@ -301,7 +301,7 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.Encrypt
},
//=========================================================================
attachmentsCount: function() {
return MochiKit.Base.keys(this.attachments()).length;
},
@@ -436,7 +436,7 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.Encrypt
}, this))
}
},
'createNewDirectLogin': function () {
this.saveOriginalDirectLoginStatusToTransientState();
@@ -689,7 +689,7 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.Encrypt
result = someFilteredResults[0];
break;
default:
//console.log("Warning: Record.fieldWithLabel('" + aLabel + "') is returning more than one result: " + someFilteredResults.length);
Clipperz.log("Warning: Record.fieldWithLabel('" + aLabel + "') is returning more than one result: " + someFilteredResults.length);
result = someFilteredResults[0];
break;
}
@@ -715,7 +715,7 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.Encrypt
var transientStateKey;
if (typeof(aVersionReference) == 'undefined') {
console.log("ERROR; getVersionKey aVersionReference is undefined");
Clipperz.log("ERROR; getVersionKey aVersionReference is undefined");
}
transientStateKey = 'versionKeys' + '.' + aVersionReference;
@@ -900,7 +900,7 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.Encrypt
]
}, {trace:true});
deferredResult.addCallback(MochiKit.Base.values);
deferredResult.addCallback(MochiKit.Base.bind(function (someValues) {
deferredResult.addCallback(MochiKit.Base.bind(function(someValues) {
return MochiKit.Iter.some(someValues, MochiKit.Base.operator.identity);
}, this));
@@ -980,7 +980,7 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.Encrypt
MochiKit.Base.method(this, 'directLogins'),
MochiKit.Base.values,
MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('revertChanges')),
MochiKit.Base.method(this, 'attachments'),
MochiKit.Base.values,
MochiKit.Base.partial(MochiKit.Base.map, MochiKit.Base.methodcaller('revertChanges')),
@@ -1048,8 +1048,8 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.Record, Clipperz.PM.DataModel.Encrypt
MochiKit.Base.bind(function () {
if (isCommitting == false) {
if (this.transientState().getValue('directLogins') != null) {
this._directLogins = this.transientState().getValue('directLogins');
}
this._directLogins = this.transientState().getValue('directLogins');
}
if (this.transientState().getValue('attachments') != null) {
this._attachments = this.transientState().getValue('attachments');
}

View File

@@ -699,7 +699,7 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, {
result = someFilteredResults[0];
break;
default:
//console.log("Warning: User.recordWithLabel('" + aLabel + "') is returning more than one result: " + someFilteredResults.length);
Clipperz.log("Warning: User.recordWithLabel('" + aLabel + "') is returning more than one result: " + someFilteredResults.length);
result = someFilteredResults[0];
break;
}

View File

@@ -126,7 +126,9 @@ MochiKit.Base.update(Clipperz.PM.UI.AttachmentController.prototype, {
var reference = anAttachment.reference()
var queueElement = this.getQueueElement(reference);
if (queueElement) {
var isElementInProgress = (queueElement && queueElement['status'] != 'DONE' && queueElement['status'] != 'CANCELED' && queueElement['status'] != 'FAILED');
if (isElementInProgress) {
deferredResult = new Clipperz.Async.Deferred("Clipperz.PM.UI.AttachmentController.cancelAttachment", {trace:false});
deferredResult.addMethod(this, 'updateFileInQueue', reference, {'status': 'CANCELED'});
if (queueElement['deferredRequest']) {

View File

@@ -41,6 +41,7 @@ Clipperz.PM.UI.Components.Cards.DetailClass = React.createClass({
result['allTags'] = this.props['allTags'];
result['preferences'] = this.props['preferences'];
result['attachmentQueueInfo'] = this.props['attachmentQueueInfo'];
result['proxyInfo'] = this.props['proxyInfo'];
}
return result;

View File

@@ -678,6 +678,9 @@ console.log("DROP"); //, anEvent);
]);
}, this.state['skippedFiles'])
),
React.DOM.a({
'onClick': MochiKit.Base.method(this, 'setState', {'skippedFiles': []}),
}, 'close'),
]);
}

View File

@@ -145,7 +145,7 @@ Clipperz.PM.UI.Components.Cards.TagEditorClass = React.createClass({
return React.DOM.div({'className':Clipperz.PM.UI.Components.classNames(classes)}, [
React.DOM.ul({},[
MochiKit.Base.map(this.renderTag, this.props['selectedTags']),
this.isReadOnly() ? null : React.DOM.li({}, React.DOM.input({'type':'text', 'list':'tagListData', 'onKeyDown':this.handleKeyDown, 'onBlur':this.handleBlur, 'placeholder': "tag"})),
this.isReadOnly() ? null : React.DOM.li({}, React.DOM.input({'type':'text', 'list':'tagListData', 'onKeyDown':this.handleKeyDown, 'onBlur':this.handleBlur, 'placeholder': "add tag"})),
]),
this.isReadOnly() ? null : this.renderEditField()
]);

View File

@@ -63,7 +63,6 @@ Clipperz.PM.UI.Components.Cards.TextAreaClass = React.createClass({
handleKeyDown: function (anEvent) {
switch (anEvent.keyCode) {
case 27: // escape
// console.log("ESCAPE");
Mousetrap.trigger('esc');
break;
}

View File

@@ -31,6 +31,7 @@ Clipperz.PM.UI.Components.Cards.ViewClass = React.createClass({
propTypes: {
'label': React.PropTypes.string /*.isRequired */ ,
'loading': React.PropTypes.bool,
'proxyInfo': React.PropTypes.object.isRequired,
},
getInitialState: function () {
@@ -265,7 +266,7 @@ Clipperz.PM.UI.Components.Cards.ViewClass = React.createClass({
renderAttachmentProgress: function(aStatus, aServerStatus, aProgress) {
var result;
var queueOperationsInProgress = (aStatus != 'DONE' && aStatus != 'CANCELED' && aStatus != 'FAILED');
var queueOperationsInProgress = (aStatus && aStatus != 'DONE' && aStatus != 'CANCELED' && aStatus != 'FAILED');
result = null;
if (aStatus == 'UPLOADING' || aStatus == 'DOWNLOADING') {
@@ -321,19 +322,21 @@ Clipperz.PM.UI.Components.Cards.ViewClass = React.createClass({
renderAttachmentActions: function(aStatus, aServerStatus, anAttachment) {
var result;
var queueOperationsInProgress = (aStatus != 'DONE' && aStatus != 'CANCELED' && aStatus != 'FAILED');
var queueOperationsInProgress = (aStatus && aStatus != 'DONE' && aStatus != 'CANCELED' && aStatus != 'FAILED');
result = null;
if (aServerStatus == 'AVAILABLE' && ! queueOperationsInProgress) {
result = React.DOM.a({
'className': 'download',
'onClick': MochiKit.Base.method(this, 'handleGetAttachment', anAttachment),
}, "\u2b07");
} else if (aServerStatus == 'AVAILABLE' && queueOperationsInProgress) {
result = React.DOM.a({
'className': 'cancel',
'onClick': MochiKit.Base.method(this, 'handleCancelDownload', anAttachment)
}, "remove field");
if (this.props['proxyInfo']['proxyType'] != 'OFFLINE_COPY') {
if (aServerStatus == 'AVAILABLE' && ! queueOperationsInProgress) {
result = React.DOM.a({
'className': 'download',
'onClick': MochiKit.Base.method(this, 'handleGetAttachment', anAttachment),
}, "\u2b07");
} else if (aServerStatus == 'AVAILABLE' && queueOperationsInProgress) {
result = React.DOM.a({
'className': 'cancel',
'onClick': MochiKit.Base.method(this, 'handleCancelDownload', anAttachment)
}, "remove field");
}
}
return result;

View File

@@ -618,7 +618,7 @@ Clipperz.log("THE BROWSER IS OFFLINE");
return deferredResult;
},
collectAttachmentInfo: function(anAttachment) {
var deferredResult;
@@ -953,7 +953,7 @@ Clipperz.log("THE BROWSER IS OFFLINE");
function (someCards) { return someCards.length; },
], {trace:false});
},
getCardsWithAttachmentsCount: function () {
var archivedCardsFilter = this.shouldIncludeArchivedCards()
? MochiKit.Async.succeed
@@ -1352,8 +1352,8 @@ Clipperz.log("THE BROWSER IS OFFLINE");
'messageBox': this.messageBoxContent(),
'userInfo': this.userInfo(),
'accountInfo': this.userAccountInfo(),
'selectionPanelStatus': this.isSelectionPanelOpen() ? 'OPEN' : 'CLOSED',
'settingsPanelStatus': this.isSettingsPanelOpen() ? 'OPEN' : 'CLOSED',
'selectionPanelStatus': this.isSelectionPanelOpen() ? 'OPEN' : 'CLOSED',
'settingsPanelStatus': this.isSettingsPanelOpen() ? 'OPEN' : 'CLOSED',
'attachmentQueueBoxStatus': this.isAttachmentQueueBoxOpen() ? 'OPEN' : 'CLOSED',
'featureSet': this.featureSet(),
'features': this.features(),
@@ -1368,6 +1368,7 @@ Clipperz.log("THE BROWSER IS OFFLINE");
} else if (aPageName == 'cardDetailPage') {
extraProperties = {
'attachmentQueueInfo': this.attachmentQueueInfo(),
'proxyInfo': this.proxyInfo(),
};
} else if (aPageName == 'errorPage') {
extraProperties = {
@@ -1936,10 +1937,10 @@ Clipperz.log("THE BROWSER IS OFFLINE");
MochiKit.Base.method(this, 'refreshUI'),
], {trace:false});
},
isPageInEditMode: function() {
var currentPage = this.pages()[this.currentPage()];
return currentPage.props['mode'] == 'edit';
return currentPage ? currentPage.props['mode'] == 'edit' : false;
},
enterEditMode: function () {
@@ -2093,11 +2094,28 @@ Clipperz.log("THE BROWSER IS OFFLINE");
//============================================================================
matchMediaQuery_handler: function (newQueryStyle) {
var wasInEditMode = this.isPageInEditMode();
var currentPage = this.currentPage();
var selectedCardInfo = this.selectedCardInfo();
this._mediaQueryStyle = newQueryStyle;
if (this.currentPage() == 'cardDetailPage') {
if (currentPage == 'cardDetailPage') {
this.moveOutPage(this.currentPage(), 'mainPage');
}
if (selectedCardInfo) {
this.pages()[currentPage].setProps({'mode': 'view'});
if (currentPage == 'mainPage' && newQueryStyle == 'narrow') {
this.selectCard(selectedCardInfo, true);
}
if (wasInEditMode) {
MochiKit.Async.callLater(0.1, MochiKit.Base.method(this, 'enterEditMode'));
MochiKit.Async.callLater(0.1, MochiKit.Base.method(this, 'updateSelectedCard', this.selectedCardInfo(), false, true));
}
}
this.resetPanels();
this.refreshCurrentPage();
},