mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Remove unnecessary files
This commit is contained in:
Binary file not shown.
@@ -1,147 +0,0 @@
|
||||
/**
|
||||
This class creates a tool form input element wrapper
|
||||
*/
|
||||
define([], function() {
|
||||
|
||||
// input field element wrapper
|
||||
return Backbone.View.extend({
|
||||
// initialize input wrapper
|
||||
initialize: function(app, options) {
|
||||
// link app
|
||||
this.app = app;
|
||||
|
||||
// set text labels and icons for optional button
|
||||
this.text_enable = app.options.text_enable || 'Enable';
|
||||
this.text_disable = app.options.text_disable || 'Disable';
|
||||
this.cls_enable = app.options.cls_enable || 'fa fa-plus-square';
|
||||
this.cls_disable = app.options.cls_disable || 'fa fa-minus-square';
|
||||
|
||||
// link field
|
||||
this.field = options.field;
|
||||
this.default_value = options.default_value;
|
||||
|
||||
// set element
|
||||
this.setElement(this._template(options));
|
||||
|
||||
// link elements
|
||||
this.$field = this.$el.find('.ui-table-form-field');
|
||||
this.$optional = this.$el.find('.ui-table-form-optional');
|
||||
this.$optional_icon = this.$el.find('.ui-table-form-optional').find('.icon');
|
||||
this.$error_text = this.$el.find('.ui-table-form-error-text');
|
||||
this.$error = this.$el.find('.ui-table-form-error');
|
||||
|
||||
// add field element
|
||||
this.$field.prepend(this.field.$el);
|
||||
|
||||
// decide wether to expand or collapse optional fields
|
||||
this.field.skip = false;
|
||||
var v = this.field.value && this.field.value();
|
||||
this.field.skip = Boolean(options.optional &&
|
||||
(v === null || v === '' || v === this.default_value ||
|
||||
String(v) === String(this.default_value) ||
|
||||
Number(v) === Number(this.default_value) ||
|
||||
JSON.stringify(v) === JSON.stringify(this.default_value)));
|
||||
|
||||
// refresh view
|
||||
this._refresh();
|
||||
|
||||
// add optional hide/show
|
||||
var self = this;
|
||||
this.$optional.on('click', function() {
|
||||
// flip flag
|
||||
self.field.skip = !self.field.skip;
|
||||
|
||||
// refresh view
|
||||
self._refresh();
|
||||
|
||||
// refresh state
|
||||
self.app.trigger('refresh');
|
||||
});
|
||||
},
|
||||
|
||||
/** Set error text
|
||||
*/
|
||||
error: function(text) {
|
||||
this.$error_text.html(text);
|
||||
this.$error.show();
|
||||
this.$el.addClass('ui-error');
|
||||
},
|
||||
|
||||
/** Reset this view
|
||||
*/
|
||||
reset: function() {
|
||||
this.$error.hide();
|
||||
this.$el.removeClass('ui-error');
|
||||
},
|
||||
|
||||
/** Refresh element
|
||||
*/
|
||||
_refresh: function() {
|
||||
// reset optional button
|
||||
this.$optional_icon.removeClass().addClass('icon');
|
||||
|
||||
// identify state
|
||||
if (!this.field.skip) {
|
||||
// enable input field
|
||||
this.$field.fadeIn('fast');
|
||||
this._tooltip(this.text_disable, this.cls_disable);
|
||||
|
||||
} else {
|
||||
// disable input field
|
||||
this.$field.hide();
|
||||
this._tooltip(this.text_enable, this.cls_enable);
|
||||
// reset field value
|
||||
this.field.value && this.field.value(this.default_value);
|
||||
}
|
||||
},
|
||||
|
||||
/** Set tooltip text
|
||||
*/
|
||||
_tooltip: function(title, cls) {
|
||||
if (this.$optional.length) {
|
||||
this.$optional_icon.addClass(cls)
|
||||
.tooltip({ placement: 'bottom' })
|
||||
.attr('data-original-title', title)
|
||||
.tooltip('fixTitle').tooltip('hide');
|
||||
}
|
||||
},
|
||||
|
||||
/** Main Template
|
||||
*/
|
||||
_template: function(options) {
|
||||
// create table element
|
||||
var tmp = '<div class="ui-table-form-element">' +
|
||||
'<div class="ui-table-form-error ui-error">' +
|
||||
'<span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"/>' +
|
||||
'</div>' +
|
||||
'<div class="ui-table-form-title">';
|
||||
|
||||
// is optional
|
||||
if (options.optional) {
|
||||
tmp += '<div class="ui-table-form-optional">' +
|
||||
'<i class="icon"/>' + options.label +
|
||||
'</div>';
|
||||
} else {
|
||||
tmp += options.label;
|
||||
}
|
||||
|
||||
// finalize title
|
||||
tmp += '</div>' +
|
||||
'<div class="ui-table-form-field">';
|
||||
|
||||
// add help
|
||||
tmp += '<div class="ui-table-form-info">';
|
||||
if (options.help) {
|
||||
tmp += options.help;
|
||||
}
|
||||
tmp += '</div>';
|
||||
|
||||
// finalize
|
||||
tmp += '</div>' +
|
||||
'</div>';
|
||||
|
||||
// return input element
|
||||
return tmp;
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,263 +0,0 @@
|
||||
/**
|
||||
This class creates input elements. New input parameter types should be added to the types dictionary.
|
||||
*/
|
||||
define(['utils/utils',
|
||||
'mvc/ui/ui-misc',
|
||||
'mvc/tools/tools-select-content',
|
||||
'mvc/ui/ui-color-picker'],
|
||||
function(Utils, Ui, SelectContent, ColorPicker) {
|
||||
|
||||
// create form view
|
||||
return Backbone.Model.extend({
|
||||
/** Available parameter types */
|
||||
types: {
|
||||
'text' : '_fieldText',
|
||||
'select' : '_fieldSelect',
|
||||
'data_column' : '_fieldSelect',
|
||||
'genomebuild' : '_fieldSelect',
|
||||
'data' : '_fieldData',
|
||||
'data_collection' : '_fieldData',
|
||||
'integer' : '_fieldSlider',
|
||||
'float' : '_fieldSlider',
|
||||
'boolean' : '_fieldBoolean',
|
||||
'drill_down' : '_fieldDrilldown',
|
||||
'color' : '_fieldColor',
|
||||
'hidden' : '_fieldHidden',
|
||||
'hidden_data' : '_fieldHidden',
|
||||
'baseurl' : '_fieldHidden',
|
||||
},
|
||||
|
||||
// initialize
|
||||
initialize: function(app, options) {
|
||||
this.app = app;
|
||||
},
|
||||
|
||||
/** Returns an input field for a given field type
|
||||
*/
|
||||
create: function(input_def) {
|
||||
// add regular/default value if missing
|
||||
if (input_def.value === undefined) {
|
||||
input_def.value = null;
|
||||
}
|
||||
if (input_def.default_value === undefined) {
|
||||
input_def.default_value = input_def.value;
|
||||
}
|
||||
|
||||
// field wrapper
|
||||
var field = null;
|
||||
|
||||
// get field class
|
||||
var fieldClass = this.types[input_def.type];
|
||||
if (fieldClass && typeof(this[fieldClass]) === 'function') {
|
||||
field = this[fieldClass].call(this, input_def);
|
||||
}
|
||||
|
||||
// identify field type
|
||||
if (!field) {
|
||||
// flag
|
||||
this.app.incompatible = true;
|
||||
|
||||
// with or without options
|
||||
if (input_def.options) {
|
||||
// assign select field
|
||||
field = this._fieldSelect(input_def);
|
||||
} else {
|
||||
// assign text field
|
||||
field = this._fieldText(input_def);
|
||||
}
|
||||
|
||||
// log
|
||||
console.debug('tools-form::_addRow() : Auto matched field type (' + input_def.type + ').');
|
||||
}
|
||||
|
||||
// set field value
|
||||
if (input_def.value !== undefined) {
|
||||
field.value(input_def.value);
|
||||
}
|
||||
|
||||
// return field element
|
||||
return field;
|
||||
},
|
||||
|
||||
/** Data input field
|
||||
*/
|
||||
_fieldData : function(input_def) {
|
||||
if (!this.app.options.is_dynamic) {
|
||||
input_def.info = 'Data input \'' + input_def.name + '\' (' + Utils.textify(input_def.extensions.toString()) + ')';
|
||||
input_def.value = null;
|
||||
return this._fieldHidden(input_def);
|
||||
}
|
||||
var self = this;
|
||||
return new SelectContent.View(this.app, {
|
||||
id : 'field-' + input_def.id,
|
||||
extensions : input_def.extensions,
|
||||
optional : input_def.optional,
|
||||
multiple : input_def.multiple,
|
||||
type : input_def.type,
|
||||
data : input_def.options,
|
||||
onchange : function() {
|
||||
self.app.trigger('refresh');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/** Select/Checkbox/Radio options field
|
||||
*/
|
||||
_fieldSelect : function (input_def) {
|
||||
// show text field in if dynamic fields are disabled e.g. in workflow editor
|
||||
if (!this.app.options.is_dynamic && input_def.is_dynamic) {
|
||||
return this._fieldText(input_def);
|
||||
}
|
||||
|
||||
// customize properties
|
||||
if (input_def.type == 'data_column') {
|
||||
input_def.error_text = 'Missing columns in referenced dataset.'
|
||||
}
|
||||
if (input_def.type == 'genomebuild') {
|
||||
input_def.searchable = true;
|
||||
}
|
||||
|
||||
// configure options fields
|
||||
var options = [];
|
||||
for (var i in input_def.options) {
|
||||
var option = input_def.options[i];
|
||||
options.push({
|
||||
label: option[0],
|
||||
value: option[1]
|
||||
});
|
||||
}
|
||||
|
||||
// identify display type
|
||||
var SelectClass = Ui.Select;
|
||||
switch (input_def.display) {
|
||||
case 'checkboxes':
|
||||
SelectClass = Ui.Checkbox;
|
||||
break;
|
||||
case 'radio':
|
||||
SelectClass = Ui.Radio;
|
||||
break;
|
||||
}
|
||||
|
||||
// select field
|
||||
var self = this;
|
||||
return new SelectClass.View({
|
||||
id : 'field-' + input_def.id,
|
||||
data : options,
|
||||
error_text : input_def.error_text || 'No options available',
|
||||
multiple : input_def.multiple,
|
||||
searchable : input_def.searchable,
|
||||
onchange : function() {
|
||||
self.app.trigger('refresh');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/** Drill down options field
|
||||
*/
|
||||
_fieldDrilldown : function (input_def) {
|
||||
// show text field in if dynamic fields are disabled e.g. in workflow editor
|
||||
if (!this.app.options.is_dynamic && input_def.is_dynamic) {
|
||||
return this._fieldText(input_def);
|
||||
}
|
||||
|
||||
// create drill down field
|
||||
var self = this;
|
||||
return new Ui.Drilldown.View({
|
||||
id : 'field-' + input_def.id,
|
||||
data : input_def.options,
|
||||
display : input_def.display,
|
||||
onchange : function() {
|
||||
self.app.trigger('refresh');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/** Text input field
|
||||
*/
|
||||
_fieldText : function(input_def) {
|
||||
// field replaces e.g. a select field
|
||||
if (input_def.options) {
|
||||
// show text area if selecting multiple entries is allowed
|
||||
input_def.area = input_def.multiple;
|
||||
|
||||
// validate value
|
||||
if (!Utils.validate(input_def.value)) {
|
||||
input_def.value = '';
|
||||
} else {
|
||||
if (input_def.value instanceof Array) {
|
||||
input_def.value = value.toString();
|
||||
} else {
|
||||
input_def.value = String(input_def.value).replace(/[\[\]'"\s]/g, '');
|
||||
if (input_def.multiple) {
|
||||
input_def.value = input_def.value.replace(/,/g, '\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// create input element
|
||||
var self = this;
|
||||
return new Ui.Input({
|
||||
id : 'field-' + input_def.id,
|
||||
area : input_def.area,
|
||||
onchange : function() {
|
||||
self.app.trigger('refresh');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/** Slider field
|
||||
*/
|
||||
_fieldSlider: function(input_def) {
|
||||
var self = this;
|
||||
return new Ui.Slider.View({
|
||||
id : 'field-' + input_def.id,
|
||||
precise : input_def.type == 'float',
|
||||
min : input_def.min,
|
||||
max : input_def.max,
|
||||
onchange : function() {
|
||||
self.app.trigger('refresh');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/** Hidden field
|
||||
*/
|
||||
_fieldHidden : function(input_def) {
|
||||
return new Ui.Hidden({
|
||||
id : 'field-' + input_def.id,
|
||||
info : input_def.info
|
||||
});
|
||||
},
|
||||
|
||||
/** Boolean field
|
||||
*/
|
||||
_fieldBoolean : function(input_def) {
|
||||
var self = this;
|
||||
return new Ui.RadioButton.View({
|
||||
id : 'field-' + input_def.id,
|
||||
data : [ { label : 'Yes', value : 'true' },
|
||||
{ label : 'No', value : 'false' }],
|
||||
onchange : function() {
|
||||
self.app.trigger('refresh');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/** Color picker field
|
||||
*/
|
||||
_fieldColor : function(input_def) {
|
||||
var self = this;
|
||||
return new ColorPicker({
|
||||
id : 'field-' + input_def.id,
|
||||
onchange : function() {
|
||||
self.app.trigger('refresh');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
View: View
|
||||
};
|
||||
});
|
||||
@@ -1,166 +0,0 @@
|
||||
// dependencies
|
||||
define(['utils/utils', 'mvc/ui/ui-table', 'mvc/ui/ui-portlet', 'mvc/ui/ui-misc'], function(Utils, Table, Portlet, Ui) {
|
||||
|
||||
/** This class creates a ui component which enables the dynamic creation of portlets
|
||||
*/
|
||||
var View = Backbone.View.extend({
|
||||
// default options
|
||||
optionsDefault : {
|
||||
title : 'Section',
|
||||
max : null,
|
||||
min : null
|
||||
},
|
||||
|
||||
/** Initialize
|
||||
*/
|
||||
initialize : function(options) {
|
||||
// configure options
|
||||
this.options = Utils.merge(options, this.optionsDefault);
|
||||
|
||||
// create new element
|
||||
this.setElement('<div/>');
|
||||
|
||||
// link this
|
||||
var self = this;
|
||||
|
||||
// create button
|
||||
this.button_new = new Ui.ButtonIcon({
|
||||
icon : 'fa-plus',
|
||||
title : 'Insert ' + options.title_new,
|
||||
tooltip : 'Add new ' + options.title_new + ' block',
|
||||
floating: 'clear',
|
||||
onclick : function() {
|
||||
if (options.onnew) {
|
||||
options.onnew();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// create table
|
||||
this.table = new Table.View({
|
||||
cls : 'ui-table-plain',
|
||||
content : ''
|
||||
});
|
||||
|
||||
// append button
|
||||
this.$el.append(this.table.$el);
|
||||
|
||||
// add button
|
||||
this.$el.append($('<div/>').append(this.button_new.$el));
|
||||
|
||||
// clear list
|
||||
this.list = {};
|
||||
|
||||
// number of available repeats
|
||||
this.n = 0;
|
||||
},
|
||||
|
||||
/** Number of repeat blocks
|
||||
*/
|
||||
size: function() {
|
||||
return this.n;
|
||||
},
|
||||
|
||||
/** Add new repeat block
|
||||
*/
|
||||
add: function(options) {
|
||||
// repeat block already exists
|
||||
if (!options.id || this.list[options.id]) {
|
||||
console.debug('tools-repeat::add - Duplicate repeat block id.');
|
||||
return;
|
||||
}
|
||||
|
||||
// increase repeat block counter
|
||||
this.n++;
|
||||
|
||||
// delete button
|
||||
var button_delete = new Ui.ButtonIcon({
|
||||
icon : 'fa-trash-o',
|
||||
tooltip : 'Delete this repeat block',
|
||||
cls : 'ui-button-icon-plain',
|
||||
onclick : function() {
|
||||
if (options.ondel) {
|
||||
options.ondel();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// create portlet
|
||||
var portlet = new Portlet.View({
|
||||
id : options.id,
|
||||
title : 'placeholder',
|
||||
cls : 'ui-portlet-repeat',
|
||||
operations : {
|
||||
button_delete : button_delete
|
||||
}
|
||||
});
|
||||
|
||||
// append content
|
||||
portlet.append(options.$el);
|
||||
|
||||
// tag as section row
|
||||
portlet.$el.addClass('section-row');
|
||||
|
||||
// append to dom
|
||||
this.list[options.id] = portlet;
|
||||
|
||||
// append to dom
|
||||
this.table.add(portlet.$el);
|
||||
this.table.append('row_' + options.id, true);
|
||||
|
||||
// validate maximum
|
||||
if (this.options.max > 0 && this.n >= this.options.max) {
|
||||
this.button_new.disable();
|
||||
}
|
||||
|
||||
// refresh view
|
||||
this._refresh();
|
||||
},
|
||||
|
||||
/** Delete repeat block
|
||||
*/
|
||||
del: function(id) {
|
||||
// could not find element
|
||||
if (!this.list[id]) {
|
||||
console.debug('tools-repeat::del - Invalid repeat block id.');
|
||||
return;
|
||||
}
|
||||
|
||||
// decrease repeat block counter
|
||||
this.n--;
|
||||
|
||||
// delete table row
|
||||
var table_row = this.table.get('row_' + id);
|
||||
table_row.remove();
|
||||
|
||||
// remove from list
|
||||
delete this.list[id];
|
||||
|
||||
// enable new button
|
||||
this.button_new.enable();
|
||||
|
||||
// refresh delete button visibility
|
||||
this._refresh();
|
||||
},
|
||||
|
||||
/** Refresh view
|
||||
*/
|
||||
_refresh: function() {
|
||||
var index = 0;
|
||||
for (var id in this.list) {
|
||||
var portlet = this.list[id];
|
||||
portlet.title(++index + ': ' + this.options.title);
|
||||
if (this.n > this.options.min) {
|
||||
portlet.showOperation('button_delete');
|
||||
} else {
|
||||
portlet.hideOperation('button_delete');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
View : View
|
||||
}
|
||||
|
||||
});
|
||||
@@ -1,343 +0,0 @@
|
||||
/**
|
||||
This class creates a tool form section and populates it with input elements. It also handles repeat blocks and conditionals by recursively creating new sub sections.
|
||||
*/
|
||||
define(['utils/utils',
|
||||
'mvc/ui/ui-table',
|
||||
'mvc/ui/ui-misc',
|
||||
'mvc/ui/ui-portlet',
|
||||
'mvc/tools/tools-repeat',
|
||||
'mvc/tools/tools-input',
|
||||
'mvc/tools/tools-parameters'],
|
||||
function(Utils, Table, Ui, Portlet, Repeat, InputElement, Parameters) {
|
||||
|
||||
// create form view
|
||||
var View = Backbone.View.extend({
|
||||
// initialize
|
||||
initialize: function(app, options) {
|
||||
// link app
|
||||
this.app = app;
|
||||
|
||||
// link inputs
|
||||
this.inputs = options.inputs;
|
||||
|
||||
// fix table style
|
||||
options.cls = 'ui-table-plain';
|
||||
|
||||
// add table class for tr tag
|
||||
// this assist in transforming the form into a json structure
|
||||
options.cls_tr = 'section-row';
|
||||
|
||||
// create table
|
||||
this.table = new Table.View(options);
|
||||
|
||||
// create parameter handler
|
||||
this.parameters = new Parameters(app, options);
|
||||
|
||||
// configure portlet and form table
|
||||
this.setElement(this.table.$el);
|
||||
|
||||
// render tool section
|
||||
this.render();
|
||||
},
|
||||
|
||||
/** Render section view
|
||||
*/
|
||||
render: function() {
|
||||
// reset table
|
||||
this.table.delAll();
|
||||
|
||||
// load settings elements into table
|
||||
for (var i in this.inputs) {
|
||||
this.add(this.inputs[i]);
|
||||
}
|
||||
},
|
||||
|
||||
/** Add a new input element
|
||||
*/
|
||||
add: function(input) {
|
||||
// link this
|
||||
var self = this;
|
||||
|
||||
// clone definition
|
||||
var input_def = jQuery.extend(true, {}, input);
|
||||
|
||||
// create unique id
|
||||
input_def.id = input.id = Utils.uuid();
|
||||
|
||||
// add to sequential list of inputs
|
||||
this.app.input_list[input_def.id] = input_def;
|
||||
|
||||
// identify field type
|
||||
var type = input_def.type;
|
||||
switch(type) {
|
||||
// conditional field
|
||||
case 'conditional':
|
||||
this._addConditional(input_def);
|
||||
break;
|
||||
// repeat block
|
||||
case 'repeat':
|
||||
this._addRepeat(input_def);
|
||||
break;
|
||||
// customized section
|
||||
case 'section':
|
||||
this._addSection(input_def);
|
||||
break;
|
||||
// default single element row
|
||||
default:
|
||||
this._addRow(input_def);
|
||||
}
|
||||
},
|
||||
|
||||
/** Add a conditional block
|
||||
*/
|
||||
_addConditional: function(input_def) {
|
||||
// link this
|
||||
var self = this;
|
||||
|
||||
// copy identifier
|
||||
input_def.test_param.id = input_def.id;
|
||||
|
||||
// build test parameter
|
||||
var field = this._addRow(input_def.test_param);
|
||||
|
||||
// set onchange event for test parameter
|
||||
field.options.onchange = function(value) {
|
||||
// identify the selected case
|
||||
var selectedCase = self.app.tree.matchCase(input_def, value);
|
||||
|
||||
// check value in order to hide/show options
|
||||
for (var i in input_def.cases) {
|
||||
// get case
|
||||
var case_def = input_def.cases[i];
|
||||
|
||||
// identify subsection name
|
||||
var section_id = input_def.id + '-section-' + i;
|
||||
|
||||
// identify row
|
||||
var section_row = self.table.get(section_id);
|
||||
|
||||
// check if non-hidden elements exist
|
||||
var nonhidden = false;
|
||||
for (var j in case_def.inputs) {
|
||||
if (!case_def.inputs[j].hidden) {
|
||||
nonhidden = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// show/hide sub form
|
||||
if (i == selectedCase && nonhidden) {
|
||||
section_row.fadeIn('fast');
|
||||
} else {
|
||||
section_row.hide();
|
||||
}
|
||||
}
|
||||
|
||||
// refresh form inputs
|
||||
self.app.trigger('refresh');
|
||||
};
|
||||
|
||||
// add conditional sub sections
|
||||
for (var i in input_def.cases) {
|
||||
// create id tag
|
||||
var sub_section_id = input_def.id + '-section-' + i;
|
||||
|
||||
// create sub section
|
||||
var sub_section = new View(this.app, {
|
||||
inputs : input_def.cases[i].inputs
|
||||
});
|
||||
|
||||
// displays as grouped subsection
|
||||
sub_section.$el.addClass('ui-table-section');
|
||||
|
||||
// create table row
|
||||
this.table.add(sub_section.$el);
|
||||
|
||||
// append to table
|
||||
this.table.append(sub_section_id);
|
||||
}
|
||||
|
||||
// trigger refresh on conditional input field after all input elements have been created
|
||||
field.trigger('change');
|
||||
},
|
||||
|
||||
/** Add a repeat block
|
||||
*/
|
||||
_addRepeat: function(input_def) {
|
||||
// link this
|
||||
var self = this;
|
||||
|
||||
// block index
|
||||
var block_index = 0;
|
||||
|
||||
// create repeat block element
|
||||
var repeat = new Repeat.View({
|
||||
title : input_def.title,
|
||||
title_new : input_def.title,
|
||||
min : input_def.min,
|
||||
max : input_def.max,
|
||||
onnew : function() {
|
||||
// create
|
||||
create(input_def.inputs);
|
||||
|
||||
// trigger refresh
|
||||
self.app.trigger('refresh');
|
||||
}
|
||||
});
|
||||
|
||||
// helper function to create new repeat blocks
|
||||
function create (inputs) {
|
||||
// create id tag
|
||||
var sub_section_id = input_def.id + '-section-' + (block_index++);
|
||||
|
||||
// create sub section
|
||||
var sub_section = new View(self.app, {
|
||||
inputs : inputs
|
||||
});
|
||||
|
||||
// add tab
|
||||
repeat.add({
|
||||
id : sub_section_id,
|
||||
$el : sub_section.$el,
|
||||
ondel : function() {
|
||||
// delete repeat block
|
||||
repeat.del(sub_section_id);
|
||||
|
||||
// trigger refresh
|
||||
self.app.trigger('refresh');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//
|
||||
// add parsed/minimum number of repeat blocks
|
||||
//
|
||||
var n_min = input_def.min;
|
||||
var n_cache = _.size(input_def.cache);
|
||||
for (var i = 0; i < Math.max(n_cache, n_min); i++) {
|
||||
var inputs = null;
|
||||
if (i < n_cache) {
|
||||
inputs = input_def.cache[i];
|
||||
} else {
|
||||
inputs = input_def.inputs;
|
||||
}
|
||||
|
||||
// create repeat block
|
||||
create(inputs);
|
||||
}
|
||||
|
||||
// create input field wrapper
|
||||
var input_element = new InputElement(this.app, {
|
||||
label : input_def.title,
|
||||
help : input_def.help,
|
||||
field : repeat
|
||||
});
|
||||
|
||||
// create table row
|
||||
this.table.add(input_element.$el);
|
||||
|
||||
// append row to table
|
||||
this.table.append(input_def.id);
|
||||
},
|
||||
|
||||
/** Add a customized section
|
||||
*/
|
||||
_addSection: function(input_def) {
|
||||
// link this
|
||||
var self = this;
|
||||
|
||||
// create sub section
|
||||
var sub_section = new View(self.app, {
|
||||
inputs : input_def.inputs
|
||||
});
|
||||
|
||||
// delete button
|
||||
var button_visible = new Ui.ButtonIcon({
|
||||
icon : 'fa-eye-slash',
|
||||
tooltip : 'Show/hide section',
|
||||
cls : 'ui-button-icon-plain'
|
||||
});
|
||||
|
||||
// create portlet for sub section
|
||||
var portlet = new Portlet.View({
|
||||
title : input_def.label,
|
||||
cls : 'ui-portlet-section',
|
||||
operations : {
|
||||
button_visible: button_visible
|
||||
}
|
||||
});
|
||||
portlet.append(sub_section.$el);
|
||||
portlet.append($('<div/>').addClass('ui-table-form-info').html(input_def.help));
|
||||
|
||||
// add event handler visibility button
|
||||
var visible = false;
|
||||
portlet.$content.hide();
|
||||
portlet.$header.css('cursor', 'pointer');
|
||||
portlet.$header.on('click', function() {
|
||||
if (visible) {
|
||||
visible = false;
|
||||
portlet.$content.hide();
|
||||
button_visible.setIcon('fa-eye-slash');
|
||||
} else {
|
||||
visible = true;
|
||||
portlet.$content.fadeIn('fast');
|
||||
button_visible.setIcon('fa-eye');
|
||||
}
|
||||
});
|
||||
|
||||
// show sub section if requested
|
||||
if (input_def.expand) {
|
||||
portlet.$header.trigger('click');
|
||||
}
|
||||
|
||||
// create table row
|
||||
this.table.add(portlet.$el);
|
||||
|
||||
// append row to table
|
||||
this.table.append(input_def.id);
|
||||
},
|
||||
|
||||
/** Add a single input field element
|
||||
*/
|
||||
_addRow: function(input_def) {
|
||||
// get id
|
||||
var id = input_def.id;
|
||||
|
||||
// create input field
|
||||
var field = this.parameters.create(input_def);
|
||||
|
||||
// add to field list
|
||||
this.app.field_list[id] = field;
|
||||
|
||||
// create input field wrapper
|
||||
var input_element = new InputElement(this.app, {
|
||||
label : input_def.label,
|
||||
default_value : input_def.default_value,
|
||||
optional : input_def.optional,
|
||||
help : input_def.help,
|
||||
field : field
|
||||
});
|
||||
|
||||
// add to element list
|
||||
this.app.element_list[id] = input_element;
|
||||
|
||||
// create table row
|
||||
this.table.add(input_element.$el);
|
||||
|
||||
// append to table
|
||||
this.table.append(id);
|
||||
|
||||
// hide row if neccessary
|
||||
if (input_def.hidden) {
|
||||
this.table.get(id).hide();
|
||||
}
|
||||
|
||||
// return created field
|
||||
return field;
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
View: View
|
||||
};
|
||||
});
|
||||
@@ -1,336 +0,0 @@
|
||||
// dependencies
|
||||
define(['utils/utils', 'mvc/ui/ui-misc', 'mvc/ui/ui-tabs', 'mvc/tools/tools-template'], function(Utils, Ui, Tabs, ToolTemplate) {
|
||||
|
||||
var View = Backbone.View.extend({
|
||||
// initialize
|
||||
initialize : function(app, options) {
|
||||
// link app and options
|
||||
this.app = app;
|
||||
this.options = options;
|
||||
|
||||
// link this
|
||||
var self = this;
|
||||
|
||||
// add element
|
||||
this.setElement('<div class="ui-select-content"/>');
|
||||
|
||||
// list of select fields
|
||||
this.list = {};
|
||||
|
||||
// radio button options
|
||||
var radio_buttons = [];
|
||||
|
||||
// identify selector type
|
||||
if (options.type == 'data_collection') {
|
||||
this.mode = 'collection';
|
||||
} else {
|
||||
if (options.multiple) {
|
||||
this.mode = 'multiple';
|
||||
} else {
|
||||
this.mode = 'single';
|
||||
}
|
||||
}
|
||||
|
||||
// set initial state
|
||||
this.current = this.mode;
|
||||
this.list = {};
|
||||
|
||||
// error messages
|
||||
var extensions = Utils.textify(options.extensions);
|
||||
var hda_error = 'No dataset available.';
|
||||
if (extensions) {
|
||||
hda_error = 'No ' + extensions + ' dataset available.';
|
||||
}
|
||||
var hdca_error = 'No dataset list available.';
|
||||
if (extensions) {
|
||||
hdca_error = 'No ' + extensions + ' dataset collection available.';
|
||||
}
|
||||
|
||||
// add single dataset selector
|
||||
if (this.mode == 'single') {
|
||||
radio_buttons.push({
|
||||
icon : 'fa-file-o',
|
||||
value : 'single',
|
||||
tooltip : 'Single dataset'
|
||||
});
|
||||
this.select_single = new Ui.Select.View({
|
||||
optional : options.optional,
|
||||
error_text : hda_error,
|
||||
onchange : function() {
|
||||
self.trigger('change');
|
||||
}
|
||||
});
|
||||
this.list['single'] = {
|
||||
field: this.select_single,
|
||||
type : 'hda'
|
||||
};
|
||||
}
|
||||
|
||||
// add multiple dataset selector
|
||||
if (this.mode == 'single' || this.mode == 'multiple') {
|
||||
radio_buttons.push({
|
||||
icon : 'fa-files-o',
|
||||
value : 'multiple',
|
||||
tooltip : 'Multiple datasets'
|
||||
});
|
||||
this.select_multiple = new Ui.Select.View({
|
||||
multiple : true,
|
||||
searchable : false,
|
||||
error_text : hda_error,
|
||||
onchange : function() {
|
||||
self.trigger('change');
|
||||
}
|
||||
});
|
||||
this.list['multiple'] = {
|
||||
field: this.select_multiple,
|
||||
type : 'hda'
|
||||
};
|
||||
}
|
||||
|
||||
// add collection selector
|
||||
if (this.mode == 'single' || this.mode == 'multiple' || this.mode == 'collection') {
|
||||
radio_buttons.push({
|
||||
icon : 'fa-folder-o',
|
||||
value : 'collection',
|
||||
tooltip : 'Dataset collection'
|
||||
});
|
||||
this.select_collection = new Ui.Select.View({
|
||||
error_text : hdca_error,
|
||||
optional : options.optional,
|
||||
onchange : function() {
|
||||
self.trigger('change');
|
||||
}
|
||||
});
|
||||
this.list['collection'] = {
|
||||
field: this.select_collection,
|
||||
type : 'hdca'
|
||||
};
|
||||
}
|
||||
|
||||
// create button
|
||||
this.button_type = new Ui.RadioButton.View({
|
||||
value : this.current,
|
||||
data : radio_buttons,
|
||||
onchange: function(value) {
|
||||
self.current = value;
|
||||
self.refresh();
|
||||
self.trigger('change');
|
||||
}
|
||||
});
|
||||
|
||||
// add batch mode information
|
||||
this.$batch = $(ToolTemplate.batchMode());
|
||||
|
||||
// number of radio buttons
|
||||
var n_buttons = _.size(this.list);
|
||||
|
||||
// add button to dom
|
||||
var button_width = 0;
|
||||
if (n_buttons > 1) {
|
||||
this.$el.append(this.button_type.$el);
|
||||
button_width = Math.max(0, _.size(this.list) * 35) + 'px';
|
||||
}
|
||||
|
||||
// append field elements
|
||||
for (var i in this.list) {
|
||||
this.$el.append(this.list[i].field.$el.css({
|
||||
'margin-left': button_width
|
||||
}));
|
||||
}
|
||||
|
||||
// append batch message
|
||||
this.$el.append(this.$batch.css({
|
||||
'margin-left': button_width
|
||||
}));
|
||||
|
||||
// update options
|
||||
this.update(options.data);
|
||||
|
||||
// set initial value
|
||||
if (this.options.value !== undefined) {
|
||||
this.value(this.options.value);
|
||||
}
|
||||
|
||||
// refresh view
|
||||
this.refresh();
|
||||
|
||||
// add change event. fires on trigger
|
||||
this.on('change', function() {
|
||||
if (options.onchange) {
|
||||
options.onchange(self.value());
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/** Indicate that select fields are being updated */
|
||||
wait: function() {
|
||||
for (var i in this.list) {
|
||||
this.list[i].field.wait();
|
||||
}
|
||||
},
|
||||
|
||||
/** Indicate that the options update has been completed */
|
||||
unwait: function() {
|
||||
for (var i in this.list) {
|
||||
this.list[i].field.unwait();
|
||||
}
|
||||
},
|
||||
|
||||
/** Update content selector */
|
||||
update: function(options) {
|
||||
// update a particular select field
|
||||
var self = this;
|
||||
function _update(field, options) {
|
||||
if (field) {
|
||||
// identify available options
|
||||
var select_options = [];
|
||||
for (var i in options) {
|
||||
var item = options[i];
|
||||
select_options.push({
|
||||
label: item.hid + ': ' + item.name,
|
||||
value: item.id
|
||||
});
|
||||
// backup to local history
|
||||
self.app.history[item.id + '_' + item.src] = item;
|
||||
}
|
||||
// update field
|
||||
field.update(select_options);
|
||||
}
|
||||
}
|
||||
|
||||
// update available options
|
||||
_update(this.select_single, options.hda);
|
||||
_update(this.select_multiple, options.hda);
|
||||
_update(this.select_collection, options.hdca);
|
||||
},
|
||||
|
||||
/** Return the currently selected dataset values */
|
||||
value : function (new_value) {
|
||||
// update current value
|
||||
if (new_value !== undefined) {
|
||||
if (new_value && new_value.values) {
|
||||
try {
|
||||
// create list with values
|
||||
var list = [];
|
||||
for (var i in new_value.values) {
|
||||
list.push(new_value.values[i].id);
|
||||
}
|
||||
|
||||
// identify suitable select field
|
||||
if (new_value && new_value.values.length > 0 && new_value.values[0].src == 'hdca') {
|
||||
this.current = 'collection';
|
||||
this.select_collection.value(list[0]);
|
||||
} else {
|
||||
if (this.mode == 'multiple') {
|
||||
this.current = 'multiple';
|
||||
this.select_multiple.value(list);
|
||||
} else {
|
||||
this.current = 'single';
|
||||
this.select_single.value(list[0]);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.debug('tools-select-content::value() - Skipped.');
|
||||
}
|
||||
} else {
|
||||
for (var i in this.list) {
|
||||
this.list[i].field.value(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// refresh view
|
||||
this.refresh();
|
||||
|
||||
// validate value
|
||||
var id_list = this._select().value();
|
||||
if (id_list === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// transform into an array
|
||||
if (!(id_list instanceof Array)) {
|
||||
id_list = [id_list];
|
||||
}
|
||||
|
||||
// check if value exists
|
||||
if (id_list.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// prepare result dict
|
||||
var result = {
|
||||
batch : this._batch(),
|
||||
values : []
|
||||
}
|
||||
|
||||
// append to dataset ids
|
||||
for (var i in id_list) {
|
||||
var details = _.findWhere(this.app.history, {
|
||||
id : id_list[i],
|
||||
src : this.list[this.current].type
|
||||
});
|
||||
if (details) {
|
||||
result.values.push(details);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// sort by history ids
|
||||
result.values.sort(function(a, b){
|
||||
return a.hid - b.hid;
|
||||
});
|
||||
|
||||
// return
|
||||
return result;
|
||||
},
|
||||
|
||||
/** Refreshes data selection view */
|
||||
refresh: function() {
|
||||
this.button_type.value(this.current);
|
||||
for (var i in this.list) {
|
||||
var $el = this.list[i].field.$el;
|
||||
if (this.current == i) {
|
||||
$el.show();
|
||||
} else {
|
||||
$el.hide();
|
||||
}
|
||||
}
|
||||
if (this._batch()) {
|
||||
this.$batch.show();
|
||||
} else {
|
||||
this.$batch.hide();
|
||||
}
|
||||
},
|
||||
|
||||
/** Assists in selecting the current field */
|
||||
_select: function() {
|
||||
return this.list[this.current].field;
|
||||
},
|
||||
|
||||
/** Assists in identifying the batch mode */
|
||||
_batch: function() {
|
||||
if (this.current == 'collection') {
|
||||
var hdca = _.findWhere(this.app.history, {
|
||||
id : this._select().value(),
|
||||
src : 'hdca'
|
||||
});
|
||||
if (hdca && hdca.map_over_type) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (this.current != 'single') {
|
||||
if (this.mode == 'single') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
View: View
|
||||
}
|
||||
|
||||
});
|
||||
@@ -1,300 +0,0 @@
|
||||
/*
|
||||
This class maps the tool form dom to an api compatible javascript dictionary.
|
||||
*/
|
||||
// dependencies
|
||||
define(['utils/utils'], function(Utils) {
|
||||
|
||||
// tool form tree
|
||||
return Backbone.Model.extend({
|
||||
// initialize
|
||||
initialize: function(app) {
|
||||
this.app = app;
|
||||
},
|
||||
|
||||
/** Convert dictionary representation into tool api specific flat dictionary format.
|
||||
*/
|
||||
finalize: function(patch) {
|
||||
// link this
|
||||
var self = this;
|
||||
|
||||
// dictionary with api specific identifiers
|
||||
this.map_dict = {};
|
||||
|
||||
// check if section is available
|
||||
if (!this.app.section) {
|
||||
return {};
|
||||
}
|
||||
|
||||
// ensure that dictionary with patching functions exists
|
||||
patch = patch || {};
|
||||
|
||||
// dictionary formatted for job submission or tool form update
|
||||
var result_dict = {};
|
||||
|
||||
// prepare full dictionary
|
||||
var dict = {};
|
||||
|
||||
// fill dictionary from dom
|
||||
this._iterate(this.app.section.$el, dict);
|
||||
|
||||
// add identifier and value to job definition
|
||||
function add(job_input_id, input_id, input_value) {
|
||||
// add entry to result dictionary
|
||||
result_dict[job_input_id] = input_value;
|
||||
|
||||
// backup id mapping
|
||||
self.map_dict[job_input_id] = input_id;
|
||||
};
|
||||
|
||||
// converter between raw dictionary and job dictionary
|
||||
function convert(identifier, head) {
|
||||
for (var index in head) {
|
||||
var node = head[index];
|
||||
if (node.input) {
|
||||
// get node
|
||||
var input = node.input;
|
||||
|
||||
// create identifier
|
||||
var job_input_id = identifier;
|
||||
if (identifier != '') {
|
||||
job_input_id += '|';
|
||||
}
|
||||
job_input_id += input.name;
|
||||
|
||||
// process input type
|
||||
switch (input.type) {
|
||||
// handle repeats
|
||||
case 'repeat':
|
||||
// section identifier
|
||||
var section_label = 'section-';
|
||||
|
||||
// collect repeat block identifiers
|
||||
var block_indices = [];
|
||||
var block_prefix = null;
|
||||
for (var block_label in node) {
|
||||
var pos = block_label.indexOf(section_label);
|
||||
if (pos != -1) {
|
||||
pos += section_label.length;
|
||||
block_indices.push(parseInt(block_label.substr(pos)));
|
||||
if (!block_prefix) {
|
||||
block_prefix = block_label.substr(0, pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sort repeat blocks
|
||||
block_indices.sort(function(a,b) { return a - b; });
|
||||
|
||||
// add to response dictionary in created order
|
||||
var index = 0;
|
||||
for (var i in block_indices) {
|
||||
convert(job_input_id + '_' + index++, node[block_prefix + block_indices[i]]);
|
||||
}
|
||||
break;
|
||||
// handle conditionals
|
||||
case 'conditional':
|
||||
// get and patch conditional value
|
||||
var value = self.app.field_list[input.id].value();
|
||||
if (patch[input.test_param.type]) {
|
||||
value = patch[input.test_param.type](value);
|
||||
}
|
||||
|
||||
// add conditional value
|
||||
add (job_input_id + '|' + input.test_param.name, input.id, value);
|
||||
|
||||
// identify selected case
|
||||
var selectedCase = self.matchCase(input, value);
|
||||
if (selectedCase != -1) {
|
||||
convert(job_input_id, head[input.id + '-section-' + selectedCase]);
|
||||
}
|
||||
break;
|
||||
// handle custom sub sections
|
||||
case 'section':
|
||||
convert('', node);
|
||||
break;
|
||||
default:
|
||||
// get field
|
||||
var field = self.app.field_list[input.id];
|
||||
if (field && field.value) {
|
||||
// validate field value
|
||||
var value = field.value();
|
||||
|
||||
// get and patch field value
|
||||
if (patch[input.type]) {
|
||||
value = patch[input.type](value);
|
||||
}
|
||||
|
||||
// ignore certain values
|
||||
if (input.ignore === undefined || input.ignore != value) {
|
||||
// add value to submission
|
||||
add (job_input_id, input.id, value);
|
||||
|
||||
// add payload to submission
|
||||
if (input.payload) {
|
||||
for (var p_id in input.payload) {
|
||||
add (p_id, input.id, input.payload[p_id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// start conversion
|
||||
convert('', dict);
|
||||
|
||||
// return result
|
||||
return result_dict;
|
||||
},
|
||||
|
||||
/** Match job definition identifier to input element identifier
|
||||
*/
|
||||
match: function (job_input_id) {
|
||||
return this.map_dict && this.map_dict[job_input_id];
|
||||
},
|
||||
|
||||
/** Match conditional values to selected cases
|
||||
*/
|
||||
matchCase: function(input, value) {
|
||||
// format value for boolean inputs
|
||||
if (input.test_param.type == 'boolean') {
|
||||
if (value == 'true') {
|
||||
value = input.test_param.truevalue || 'true';
|
||||
} else {
|
||||
value = input.test_param.falsevalue || 'false';
|
||||
}
|
||||
}
|
||||
|
||||
// find selected case
|
||||
for (var i in input.cases) {
|
||||
if (input.cases[i].value == value) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
// selected case not found
|
||||
return -1;
|
||||
},
|
||||
|
||||
/** Matches identifier from api model to input elements
|
||||
*/
|
||||
matchModel: function(model, callback) {
|
||||
// final result dictionary
|
||||
var result = {};
|
||||
|
||||
// link this
|
||||
var self = this;
|
||||
|
||||
// search throughout response
|
||||
function search (id, head) {
|
||||
for (var i in head) {
|
||||
var node = head[i];
|
||||
var index = node.name;
|
||||
if (id != '') {
|
||||
index = id + '|' + index;
|
||||
}
|
||||
switch (node.type) {
|
||||
case 'repeat':
|
||||
for (var j in node.cache) {
|
||||
search (index + '_' + j, node.cache[j]);
|
||||
}
|
||||
break;
|
||||
case 'conditional':
|
||||
var value = node.test_param && node.test_param.value;
|
||||
var selectedCase = self.matchCase(node, value);
|
||||
if (selectedCase != -1) {
|
||||
search (index, node.cases[selectedCase].inputs);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
var input_id = self.map_dict[index];
|
||||
if (input_id) {
|
||||
callback(input_id, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// match all ids and return messages
|
||||
search('', model.inputs);
|
||||
|
||||
// return matched results
|
||||
return result;
|
||||
},
|
||||
|
||||
/** Matches identifier from api response to input elements
|
||||
*/
|
||||
matchResponse: function(response) {
|
||||
// final result dictionary
|
||||
var result = {};
|
||||
|
||||
// link this
|
||||
var self = this;
|
||||
|
||||
// search throughout response
|
||||
function search (id, head) {
|
||||
if (typeof head === 'string') {
|
||||
var input_id = self.map_dict[id];
|
||||
if (input_id) {
|
||||
result[input_id] = head;
|
||||
}
|
||||
} else {
|
||||
for (var i in head) {
|
||||
var new_id = i;
|
||||
if (id !== '') {
|
||||
var separator = '|';
|
||||
if (head instanceof Array) {
|
||||
separator = '_';
|
||||
}
|
||||
new_id = id + separator + new_id;
|
||||
}
|
||||
search (new_id, head[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// match all ids and return messages
|
||||
search('', response);
|
||||
|
||||
// return matched results
|
||||
return result;
|
||||
},
|
||||
|
||||
/** Iterate through the tool form dom and map it to the dictionary.
|
||||
*/
|
||||
_iterate: function(parent, dict) {
|
||||
// get child nodes
|
||||
var self = this;
|
||||
var children = $(parent).children();
|
||||
children.each(function() {
|
||||
// get child element
|
||||
var child = this;
|
||||
|
||||
// get id
|
||||
var id = $(child).attr('id');
|
||||
|
||||
// create new branch
|
||||
if ($(child).hasClass('section-row')) {
|
||||
// create sub dictionary
|
||||
dict[id] = {};
|
||||
|
||||
// add input element if it exists
|
||||
var input = self.app.input_list[id];
|
||||
if (input) {
|
||||
dict[id] = {
|
||||
input : input
|
||||
}
|
||||
}
|
||||
|
||||
// fill sub dictionary
|
||||
self._iterate(child, dict[id]);
|
||||
} else {
|
||||
self._iterate(child, dict);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1 +0,0 @@
|
||||
define([],function(){return Backbone.View.extend({initialize:function(d,c){this.app=d;this.text_enable=d.options.text_enable||"Enable";this.text_disable=d.options.text_disable||"Disable";this.cls_enable=d.options.cls_enable||"fa fa-plus-square";this.cls_disable=d.options.cls_disable||"fa fa-minus-square";this.field=c.field;this.default_value=c.default_value;this.setElement(this._template(c));this.$field=this.$el.find(".ui-table-form-field");this.$optional=this.$el.find(".ui-table-form-optional");this.$optional_icon=this.$el.find(".ui-table-form-optional").find(".icon");this.$error_text=this.$el.find(".ui-table-form-error-text");this.$error=this.$el.find(".ui-table-form-error");this.$field.prepend(this.field.$el);this.field.skip=false;var b=this.field.value&&this.field.value();this.field.skip=Boolean(c.optional&&(b===null||b===""||b===this.default_value||String(b)===String(this.default_value)||Number(b)===Number(this.default_value)||JSON.stringify(b)===JSON.stringify(this.default_value)));this._refresh();var a=this;this.$optional.on("click",function(){a.field.skip=!a.field.skip;a._refresh();a.app.trigger("refresh")})},error:function(a){this.$error_text.html(a);this.$error.show();this.$el.addClass("ui-error")},reset:function(){this.$error.hide();this.$el.removeClass("ui-error")},_refresh:function(){this.$optional_icon.removeClass().addClass("icon");if(!this.field.skip){this.$field.fadeIn("fast");this._tooltip(this.text_disable,this.cls_disable)}else{this.$field.hide();this._tooltip(this.text_enable,this.cls_enable);this.field.value&&this.field.value(this.default_value)}},_tooltip:function(b,a){if(this.$optional.length){this.$optional_icon.addClass(a).tooltip({placement:"bottom"}).attr("data-original-title",b).tooltip("fixTitle").tooltip("hide")}},_template:function(a){var b='<div class="ui-table-form-element"><div class="ui-table-form-error ui-error"><span class="fa fa-arrow-down"/><span class="ui-table-form-error-text"/></div><div class="ui-table-form-title">';if(a.optional){b+='<div class="ui-table-form-optional"><i class="icon"/>'+a.label+"</div>"}else{b+=a.label}b+='</div><div class="ui-table-form-field">';b+='<div class="ui-table-form-info">';if(a.help){b+=a.help}b+="</div>";b+="</div></div>";return b}})});
|
||||
@@ -1 +0,0 @@
|
||||
define(["utils/utils","mvc/ui/ui-misc","mvc/tools/tools-select-content","mvc/ui/ui-color-picker"],function(c,d,a,b){return Backbone.Model.extend({types:{text:"_fieldText",select:"_fieldSelect",data_column:"_fieldSelect",genomebuild:"_fieldSelect",data:"_fieldData",data_collection:"_fieldData",integer:"_fieldSlider","float":"_fieldSlider","boolean":"_fieldBoolean",drill_down:"_fieldDrilldown",color:"_fieldColor",hidden:"_fieldHidden",hidden_data:"_fieldHidden",baseurl:"_fieldHidden",},initialize:function(f,e){this.app=f},create:function(e){if(e.value===undefined){e.value=null}if(e.default_value===undefined){e.default_value=e.value}var g=null;var f=this.types[e.type];if(f&&typeof(this[f])==="function"){g=this[f].call(this,e)}if(!g){this.app.incompatible=true;if(e.options){g=this._fieldSelect(e)}else{g=this._fieldText(e)}console.debug("tools-form::_addRow() : Auto matched field type ("+e.type+").")}if(e.value!==undefined){g.value(e.value)}return g},_fieldData:function(e){if(!this.app.options.is_dynamic){e.info="Data input '"+e.name+"' ("+c.textify(e.extensions.toString())+")";e.value=null;return this._fieldHidden(e)}var f=this;return new a.View(this.app,{id:"field-"+e.id,extensions:e.extensions,optional:e.optional,multiple:e.multiple,type:e.type,data:e.options,onchange:function(){f.app.trigger("refresh")}})},_fieldSelect:function(e){if(!this.app.options.is_dynamic&&e.is_dynamic){return this._fieldText(e)}if(e.type=="data_column"){e.error_text="Missing columns in referenced dataset."}if(e.type=="genomebuild"){e.searchable=true}var g=[];for(var h in e.options){var j=e.options[h];g.push({label:j[0],value:j[1]})}var k=d.Select;switch(e.display){case"checkboxes":k=d.Checkbox;break;case"radio":k=d.Radio;break}var f=this;return new k.View({id:"field-"+e.id,data:g,error_text:e.error_text||"No options available",multiple:e.multiple,searchable:e.searchable,onchange:function(){f.app.trigger("refresh")}})},_fieldDrilldown:function(e){if(!this.app.options.is_dynamic&&e.is_dynamic){return this._fieldText(e)}var f=this;return new d.Drilldown.View({id:"field-"+e.id,data:e.options,display:e.display,onchange:function(){f.app.trigger("refresh")}})},_fieldText:function(e){if(e.options){e.area=e.multiple;if(!c.validate(e.value)){e.value=""}else{if(e.value instanceof Array){e.value=value.toString()}else{e.value=String(e.value).replace(/[\[\]'"\s]/g,"");if(e.multiple){e.value=e.value.replace(/,/g,"\n")}}}}var f=this;return new d.Input({id:"field-"+e.id,area:e.area,onchange:function(){f.app.trigger("refresh")}})},_fieldSlider:function(e){var f=this;return new d.Slider.View({id:"field-"+e.id,precise:e.type=="float",min:e.min,max:e.max,onchange:function(){f.app.trigger("refresh")}})},_fieldHidden:function(e){return new d.Hidden({id:"field-"+e.id,info:e.info})},_fieldBoolean:function(e){var f=this;return new d.RadioButton.View({id:"field-"+e.id,data:[{label:"Yes",value:"true"},{label:"No",value:"false"}],onchange:function(){f.app.trigger("refresh")}})},_fieldColor:function(e){var f=this;return new b({id:"field-"+e.id,onchange:function(){f.app.trigger("refresh")}})}});return{View:View}});
|
||||
@@ -1 +0,0 @@
|
||||
define(["utils/utils","mvc/ui/ui-table","mvc/ui/ui-portlet","mvc/ui/ui-misc"],function(c,a,b,e){var d=Backbone.View.extend({optionsDefault:{title:"Section",max:null,min:null},initialize:function(g){this.options=c.merge(g,this.optionsDefault);this.setElement("<div/>");var f=this;this.button_new=new e.ButtonIcon({icon:"fa-plus",title:"Insert "+g.title_new,tooltip:"Add new "+g.title_new+" block",floating:"clear",onclick:function(){if(g.onnew){g.onnew()}}});this.table=new a.View({cls:"ui-table-plain",content:""});this.$el.append(this.table.$el);this.$el.append($("<div/>").append(this.button_new.$el));this.list={};this.n=0},size:function(){return this.n},add:function(g){if(!g.id||this.list[g.id]){console.debug("tools-repeat::add - Duplicate repeat block id.");return}this.n++;var f=new e.ButtonIcon({icon:"fa-trash-o",tooltip:"Delete this repeat block",cls:"ui-button-icon-plain",onclick:function(){if(g.ondel){g.ondel()}}});var h=new b.View({id:g.id,title:"placeholder",cls:"ui-portlet-repeat",operations:{button_delete:f}});h.append(g.$el);h.$el.addClass("section-row");this.list[g.id]=h;this.table.add(h.$el);this.table.append("row_"+g.id,true);if(this.options.max>0&&this.n>=this.options.max){this.button_new.disable()}this._refresh()},del:function(g){if(!this.list[g]){console.debug("tools-repeat::del - Invalid repeat block id.");return}this.n--;var f=this.table.get("row_"+g);f.remove();delete this.list[g];this.button_new.enable();this._refresh()},_refresh:function(){var f=0;for(var h in this.list){var g=this.list[h];g.title(++f+": "+this.options.title);if(this.n>this.options.min){g.showOperation("button_delete")}else{g.hideOperation("button_delete")}}}});return{View:d}});
|
||||
@@ -1 +0,0 @@
|
||||
define(["utils/utils","mvc/ui/ui-table","mvc/ui/ui-misc","mvc/ui/ui-portlet","mvc/tools/tools-repeat","mvc/tools/tools-input","mvc/tools/tools-parameters"],function(e,a,h,d,c,f,b){var g=Backbone.View.extend({initialize:function(j,i){this.app=j;this.inputs=i.inputs;i.cls="ui-table-plain";i.cls_tr="section-row";this.table=new a.View(i);this.parameters=new b(j,i);this.setElement(this.table.$el);this.render()},render:function(){this.table.delAll();for(var j in this.inputs){this.add(this.inputs[j])}},add:function(k){var j=this;var i=jQuery.extend(true,{},k);i.id=k.id=e.uuid();this.app.input_list[i.id]=i;var l=i.type;switch(l){case"conditional":this._addConditional(i);break;case"repeat":this._addRepeat(i);break;case"section":this._addSection(i);break;default:this._addRow(i)}},_addConditional:function(j){var k=this;j.test_param.id=j.id;var n=this._addRow(j.test_param);n.options.onchange=function(w){var v=k.app.tree.matchCase(j,w);for(var u in j.cases){var q=j.cases[u];var t=j.id+"-section-"+u;var p=k.table.get(t);var s=false;for(var r in q.inputs){if(!q.inputs[r].hidden){s=true;break}}if(u==v&&s){p.fadeIn("fast")}else{p.hide()}}k.app.trigger("refresh")};for(var m in j.cases){var l=j.id+"-section-"+m;var o=new g(this.app,{inputs:j.cases[m].inputs});o.$el.addClass("ui-table-section");this.table.add(o.$el);this.table.append(l)}n.trigger("change")},_addRepeat:function(p){var s=this;var q=0;var l=new c.View({title:p.title,title_new:p.title,min:p.min,max:p.max,onnew:function(){n(p.inputs);s.app.trigger("refresh")}});function n(i){var t=p.id+"-section-"+(q++);var u=new g(s.app,{inputs:i});l.add({id:t,$el:u.$el,ondel:function(){l.del(t);s.app.trigger("refresh")}})}var j=p.min;var r=_.size(p.cache);for(var m=0;m<Math.max(r,j);m++){var o=null;if(m<r){o=p.cache[m]}else{o=p.inputs}n(o)}var k=new f(this.app,{label:p.title,help:p.help,field:l});this.table.add(k.$el);this.table.append(p.id)},_addSection:function(i){var j=this;var n=new g(j.app,{inputs:i.inputs});var m=new h.ButtonIcon({icon:"fa-eye-slash",tooltip:"Show/hide section",cls:"ui-button-icon-plain"});var l=new d.View({title:i.label,cls:"ui-portlet-section",operations:{button_visible:m}});l.append(n.$el);l.append($("<div/>").addClass("ui-table-form-info").html(i.help));var k=false;l.$content.hide();l.$header.css("cursor","pointer");l.$header.on("click",function(){if(k){k=false;l.$content.hide();m.setIcon("fa-eye-slash")}else{k=true;l.$content.fadeIn("fast");m.setIcon("fa-eye")}});if(i.expand){l.$header.trigger("click")}this.table.add(l.$el);this.table.append(i.id)},_addRow:function(i){var l=i.id;var j=this.parameters.create(i);this.app.field_list[l]=j;var k=new f(this.app,{label:i.label,default_value:i.default_value,optional:i.optional,help:i.help,field:j});this.app.element_list[l]=k;this.table.add(k.$el);this.table.append(l);if(i.hidden){this.table.get(l).hide()}return j}});return{View:g}});
|
||||
@@ -1 +0,0 @@
|
||||
define(["utils/utils","mvc/ui/ui-misc","mvc/ui/ui-tabs","mvc/tools/tools-template"],function(c,e,b,a){var d=Backbone.View.extend({initialize:function(g,p){this.app=g;this.options=p;var o=this;this.setElement('<div class="ui-select-content"/>');this.list={};var m=[];if(p.type=="data_collection"){this.mode="collection"}else{if(p.multiple){this.mode="multiple"}else{this.mode="single"}}this.current=this.mode;this.list={};var k=c.textify(p.extensions);var j="No dataset available.";if(k){j="No "+k+" dataset available."}var l="No dataset list available.";if(k){l="No "+k+" dataset collection available."}if(this.mode=="single"){m.push({icon:"fa-file-o",value:"single",tooltip:"Single dataset"});this.select_single=new e.Select.View({optional:p.optional,error_text:j,onchange:function(){o.trigger("change")}});this.list.single={field:this.select_single,type:"hda"}}if(this.mode=="single"||this.mode=="multiple"){m.push({icon:"fa-files-o",value:"multiple",tooltip:"Multiple datasets"});this.select_multiple=new e.Select.View({multiple:true,searchable:false,error_text:j,onchange:function(){o.trigger("change")}});this.list.multiple={field:this.select_multiple,type:"hda"}}if(this.mode=="single"||this.mode=="multiple"||this.mode=="collection"){m.push({icon:"fa-folder-o",value:"collection",tooltip:"Dataset collection"});this.select_collection=new e.Select.View({error_text:l,optional:p.optional,onchange:function(){o.trigger("change")}});this.list.collection={field:this.select_collection,type:"hdca"}}this.button_type=new e.RadioButton.View({value:this.current,data:m,onchange:function(i){o.current=i;o.refresh();o.trigger("change")}});this.$batch=$(a.batchMode());var f=_.size(this.list);var n=0;if(f>1){this.$el.append(this.button_type.$el);n=Math.max(0,_.size(this.list)*35)+"px"}for(var h in this.list){this.$el.append(this.list[h].field.$el.css({"margin-left":n}))}this.$el.append(this.$batch.css({"margin-left":n}));this.update(p.data);if(this.options.value!==undefined){this.value(this.options.value)}this.refresh();this.on("change",function(){if(p.onchange){p.onchange(o.value())}})},wait:function(){for(var f in this.list){this.list[f].field.wait()}},unwait:function(){for(var f in this.list){this.list[f].field.unwait()}},update:function(h){var f=this;function g(m,j){if(m){var n=[];for(var k in j){var l=j[k];n.push({label:l.hid+": "+l.name,value:l.id});f.app.history[l.id+"_"+l.src]=l}m.update(n)}}g(this.select_single,h.hda);g(this.select_multiple,h.hda);g(this.select_collection,h.hdca)},value:function(j){if(j!==undefined){if(j&&j.values){try{var m=[];for(var h in j.values){m.push(j.values[h].id)}if(j&&j.values.length>0&&j.values[0].src=="hdca"){this.current="collection";this.select_collection.value(m[0])}else{if(this.mode=="multiple"){this.current="multiple";this.select_multiple.value(m)}else{this.current="single";this.select_single.value(m[0])}}}catch(l){console.debug("tools-select-content::value() - Skipped.")}}else{for(var h in this.list){this.list[h].field.value(null)}}}this.refresh();var k=this._select().value();if(k===null){return null}if(!(k instanceof Array)){k=[k]}if(k.length===0){return null}var f={batch:this._batch(),values:[]};for(var h in k){var g=_.findWhere(this.app.history,{id:k[h],src:this.list[this.current].type});if(g){f.values.push(g)}else{return null}}f.values.sort(function(n,i){return n.hid-i.hid});return f},refresh:function(){this.button_type.value(this.current);for(var g in this.list){var f=this.list[g].field.$el;if(this.current==g){f.show()}else{f.hide()}}if(this._batch()){this.$batch.show()}else{this.$batch.hide()}},_select:function(){return this.list[this.current].field},_batch:function(){if(this.current=="collection"){var f=_.findWhere(this.app.history,{id:this._select().value(),src:"hdca"});if(f&&f.map_over_type){return true}}if(this.current!="single"){if(this.mode=="single"){return true}}return false}});return{View:d}});
|
||||
@@ -1 +0,0 @@
|
||||
define(["utils/utils"],function(a){return Backbone.Model.extend({initialize:function(b){this.app=b},finalize:function(g){var b=this;this.map_dict={};if(!this.app.section){return{}}g=g||{};var f={};var e={};this._iterate(this.app.section.$el,e);function d(j,i,h){f[j]=h;b.map_dict[j]=i}function c(p,s){for(var n in s){var k=s[n];if(k.input){var u=k.input;var o=p;if(p!=""){o+="|"}o+=u.name;switch(u.type){case"repeat":var j="section-";var x=[];var r=null;for(var w in k){var q=w.indexOf(j);if(q!=-1){q+=j.length;x.push(parseInt(w.substr(q)));if(!r){r=w.substr(0,q)}}}x.sort(function(y,i){return y-i});var n=0;for(var l in x){c(o+"_"+n++,k[r+x[l]])}break;case"conditional":var v=b.app.field_list[u.id].value();if(g[u.test_param.type]){v=g[u.test_param.type](v)}d(o+"|"+u.test_param.name,u.id,v);var h=b.matchCase(u,v);if(h!=-1){c(o,s[u.id+"-section-"+h])}break;case"section":c("",k);break;default:var t=b.app.field_list[u.id];if(t&&t.value){var v=t.value();if(g[u.type]){v=g[u.type](v)}if(u.ignore===undefined||u.ignore!=v){d(o,u.id,v);if(u.payload){for(var m in u.payload){d(m,u.id,u.payload[m])}}}}}}}}c("",e);return f},match:function(b){return this.map_dict&&this.map_dict[b]},matchCase:function(b,d){if(b.test_param.type=="boolean"){if(d=="true"){d=b.test_param.truevalue||"true"}else{d=b.test_param.falsevalue||"false"}}for(var c in b.cases){if(b.cases[c].value==d){return c}}return -1},matchModel:function(d,f){var b={};var c=this;function e(g,p){for(var m in p){var k=p[m];var n=k.name;if(g!=""){n=g+"|"+n}switch(k.type){case"repeat":for(var l in k.cache){e(n+"_"+l,k.cache[l])}break;case"conditional":var q=k.test_param&&k.test_param.value;var h=c.matchCase(k,q);if(h!=-1){e(n,k.cases[h].inputs)}break;default:var o=c.map_dict[n];if(o){f(o,k)}}}}e("",d.inputs);return b},matchResponse:function(d){var b={};var c=this;function e(l,j){if(typeof j==="string"){var g=c.map_dict[l];if(g){b[g]=j}}else{for(var h in j){var f=h;if(l!==""){var k="|";if(j instanceof Array){k="_"}f=l+k+f}e(f,j[h])}}}e("",d);return b},_iterate:function(d,e){var b=this;var c=$(d).children();c.each(function(){var h=this;var g=$(h).attr("id");if($(h).hasClass("section-row")){e[g]={};var f=b.app.input_list[g];if(f){e[g]={input:f}}b._iterate(h,e[g])}else{b._iterate(h,e)}})}})});
|
||||
Reference in New Issue
Block a user