fix #224: group info in entry details

This commit is contained in:
antelle 2016-06-04 15:47:56 +03:00
parent 556a7b3236
commit bd3423cec1
6 changed files with 52 additions and 8 deletions

View File

@ -31,6 +31,7 @@ var EntryModel = Backbone.Model.extend({
var entry = this.entry;
this.set({id: entry.uuid.id}, {silent: true});
this.fileName = this.file.get('name');
this.groupName = this.group.get('title');
this.title = entry.fields.Title || '';
this.password = entry.fields.Password || kdbxweb.ProtectedValue.fromString('');
this.notes = entry.fields.Notes || '';
@ -496,6 +497,16 @@ var EntryModel = Backbone.Model.extend({
this._entryModified();
this.entry.autoType.defaultSequence = seq || undefined;
this._buildAutoType();
},
getGroupPath: function() {
var group = this.group;
var groupPath = [];
while (group) {
groupPath.unshift(group.get('title'));
group = group.parentGroup;
}
return groupPath;
}
});

View File

@ -200,6 +200,7 @@ var Locale = {
detExpires: 'Expires',
detExpired: 'expired',
detFile: 'File',
detGroup: 'Group',
detCreated: 'Created',
detUpdated: 'Updated',
detHistory: 'History',

View File

@ -139,21 +139,35 @@ Tip.createTips = function(container) {
return;
}
container.find('[title]').each(function(ix, el) {
var tip = new Tip($(el));
tip.init();
el._tip = tip;
Tip.createTip(el);
});
};
Tip.createTip = function(el) {
if (!Tip.enabled) {
return;
}
var tip = new Tip($(el));
tip.init();
el._tip = tip;
};
Tip.hideTips = function(container) {
if (!Tip.enabled) {
return;
}
container.find('[data-title]').each(function(ix, el) {
if (el._tip) {
el._tip.hide();
}
Tip.hideTip(el);
});
};
Tip.hideTip = function(el) {
if (!Tip.enabled) {
return;
}
if (el._tip) {
el._tip.hide();
}
};
module.exports = Tip;

View File

@ -151,6 +151,8 @@ var DetailsView = Backbone.View.extend({
value: function() { return model.expires; } } }));
this.fieldViews.push(new FieldViewReadOnly({ model: { name: 'File', title: Locale.detFile,
value: function() { return model.fileName; } } }));
this.fieldViews.push(new FieldViewReadOnly({ model: { name: 'Group', title: Locale.detGroup,
value: function() { return model.groupName; }, tip: function() { return model.getGroupPath().join(' / '); } } }));
this.fieldViews.push(new FieldViewReadOnly({ model: { name: 'Created', title: Locale.detCreated,
value: function() { return Format.dtStr(model.created); } } }));
this.fieldViews.push(new FieldViewReadOnly({ model: { name: 'Updated', title: Locale.detUpdated,

View File

@ -2,7 +2,8 @@
var Backbone = require('backbone'),
FeatureDetector = require('../../util/feature-detector'),
CopyPaste = require('../../comp/copy-paste');
CopyPaste = require('../../comp/copy-paste'),
Tip = require('../../util/tip');
var FieldView = Backbone.View.extend({
template: require('templates/details/field.hbs'),
@ -12,16 +13,30 @@ var FieldView = Backbone.View.extend({
'click .details__field-value': 'fieldValueClick'
},
render: function () {
render: function() {
this.value = typeof this.model.value === 'function' ? this.model.value() : this.model.value;
this.renderTemplate({ editable: !this.readonly, multiline: this.model.multiline, title: this.model.title,
canEditTitle: this.model.newField, protect: this.value && this.value.isProtected });
this.valueEl = this.$el.find('.details__field-value');
this.valueEl.html(this.renderValue(this.value));
this.labelEl = this.$el.find('.details__field-label');
if (this.model.tip) {
this.tip = typeof this.model.tip === 'function' ? this.model.tip() : this.model.tip;
if (this.tip) {
this.valueEl.attr('title', this.tip);
Tip.createTip(this.valueEl);
}
}
return this;
},
remove: function() {
if (this.tip) {
Tip.hideTip(this.valueEl);
}
Backbone.View.prototype.remove.apply(this, arguments);
},
update: function() {
if (typeof this.model.value === 'function') {
var newVal = this.model.value();

View File

@ -12,6 +12,7 @@ Auto-type, ui improvements
`+` ability to increase font size
`+` improved start page ux on mobile
`+` option to show app logs
`+` group info in entry details
`*` don't check updates at startup
`-` prevent second app instance on windows
`-` fix drag-drop in Safari