add support for data annotations
This commit is contained in:
parent
33a7832d64
commit
8243614546
5 changed files with 77 additions and 34 deletions
|
|
@ -121,7 +121,7 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
self.$widget.options({width: self.options.width});
|
||||
}
|
||||
self.$annotations.options({
|
||||
width: self.options.type == 'text'
|
||||
width: isTextType(self.options.type)
|
||||
? self.options.width + 8
|
||||
: self.options.width
|
||||
});
|
||||
|
|
@ -284,7 +284,7 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
clickLink: self.options.clickLink,
|
||||
confirmDeleteDialog: self.options.confirmDeleteDialog,
|
||||
editable: self.options.editable,
|
||||
getSortValue: self.options.type == 'text'
|
||||
getSortValue: isTextType(self.options.type)
|
||||
? function(value) {
|
||||
return Ox.stripTags(value);
|
||||
}
|
||||
|
|
@ -301,8 +301,24 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
+ Ox.formatDate(item.modified.slice(0, 10), '%B %e, %Y');
|
||||
} : '',
|
||||
width: self.options.width,
|
||||
maxHeight: self.options.type == 'text' ? Infinity : void 0,
|
||||
type: self.options.type == 'text' ? 'textarea' : 'input'
|
||||
maxHeight: isTextType(self.options.type) ? Infinity : void 0,
|
||||
type: self.options.type == 'data' ? 'data' : self.options.type == 'text' ? 'textarea' : 'input',
|
||||
format: self.options.type == 'data' ? function(value) {
|
||||
return Ox.TreeList({
|
||||
data: value,
|
||||
width: self.options.width
|
||||
}).css({
|
||||
minHeight: '256px',
|
||||
});
|
||||
} : self.options.translate ? function(value) {
|
||||
return Ox._(value);
|
||||
} : null,
|
||||
unformat: function(value) {
|
||||
if (self.options.type == 'data') {
|
||||
return JSON.stringify(value, null, " ");
|
||||
}
|
||||
return Ox.decodeHTMLEntities(Ox.stripTags(value));
|
||||
}
|
||||
}, self.options.autocomplete ? {
|
||||
autocomplete: function(value, callback) {
|
||||
self.options.autocomplete(self.options.id, value, callback);
|
||||
|
|
@ -313,14 +329,9 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
autocompleteSelectHighlight: true,
|
||||
autocompleteSelectMaxWidth: 256,
|
||||
autocompleteSelectOffset: {left: 0, top: 0},
|
||||
autocompleteSelectUpdate: true,
|
||||
format: self.options.translate ? function(value) {
|
||||
return Ox._(value);
|
||||
} : null,
|
||||
unformat: function(value) {
|
||||
return Ox.decodeHTMLEntities(Ox.stripTags(value));
|
||||
}
|
||||
} : {}))
|
||||
autocompleteSelectUpdate: true
|
||||
} : {
|
||||
}))
|
||||
.bindEvent({
|
||||
add: function(data) {
|
||||
if (self.editing) {
|
||||
|
|
@ -548,8 +559,8 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
|
||||
function getSort() {
|
||||
return ({
|
||||
duration: ['-duration', '+in', self.options.type == 'text' ? '+created' : '+value'],
|
||||
position: ['+in', '+duration', self.options.type == 'text' ? '+created' : '+value'],
|
||||
duration: ['-duration', '+in', isTextType(self.options.type) ? '+created' : '+value'],
|
||||
position: ['+in', '+duration', isTextType(self.options.type) ? '+created' : '+value'],
|
||||
text: ['+value', '+in', '+duration'],
|
||||
created: ['+created', '+in', '+duration', '+value']
|
||||
})[self.options.sort];
|
||||
|
|
@ -560,6 +571,10 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
&& !!item[self.options.type].type;
|
||||
}
|
||||
|
||||
function isTextType(type) {
|
||||
return ['text', 'data'].includes(type);
|
||||
}
|
||||
|
||||
function removeAnnotation(data) {
|
||||
var item;
|
||||
self.editing = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue