mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-30 20:23:14 +08:00
code style fixes
This commit is contained in:
parent
3eef4f87bf
commit
43903080ce
2 changed files with 21 additions and 20 deletions
|
@ -13,8 +13,8 @@
|
||||||
*/
|
*/
|
||||||
global.RepositoryItemEditForm = function(itemData, repositoryItemElement) {
|
global.RepositoryItemEditForm = function(itemData, repositoryItemElement) {
|
||||||
this.itemData = itemData;
|
this.itemData = itemData;
|
||||||
this.repositoryItemElement = repositoryItemElement
|
this.repositoryItemElement = repositoryItemElement;
|
||||||
this.formData = this.composeFormData(itemData)
|
this.formData = this.composeFormData(itemData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
RepositoryItemEditForm.prototype.renderForm = function(table) {
|
RepositoryItemEditForm.prototype.renderForm = function(table) {
|
||||||
var colIndex = getColumnIndex(table, '#row-name');
|
var colIndex = getColumnIndex(table, '#row-name');
|
||||||
var cells = this.itemData.repository_row.repository_cells;
|
var cells = this.itemData.repository_row.repository_cells;
|
||||||
var list_columns = this.itemData.repository_row.repository_column_items;
|
var listColumns = this.itemData.repository_row.repository_column_items;
|
||||||
var formData = this.formData;
|
var formData = this.formData;
|
||||||
|
|
||||||
if (colIndex) {
|
if (colIndex) {
|
||||||
|
@ -50,8 +50,8 @@
|
||||||
colHeaderId,
|
colHeaderId,
|
||||||
type,
|
type,
|
||||||
cell,
|
cell,
|
||||||
list_columns));
|
listColumns));
|
||||||
_addSelectedFile(type, cell, colHeaderId, formData);
|
addSelectedFile(type, colHeaderId);
|
||||||
appendNewElementToFormData(cell, colHeaderId, formData);
|
appendNewElementToFormData(cell, colHeaderId, formData);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -223,16 +223,16 @@
|
||||||
*
|
*
|
||||||
* @param {Array} options
|
* @param {Array} options
|
||||||
* @param {String} current_value
|
* @param {String} current_value
|
||||||
* @param {Number} column_id
|
* @param {Number} columnId
|
||||||
* @param {String} id
|
* @param {String} id
|
||||||
*
|
*
|
||||||
* @returns (String)
|
* @returns (String)
|
||||||
*/
|
*/
|
||||||
function _listItemDropdown(options, current_value, column_id, id) {
|
function _listItemDropdown(options, current_value, columnId, id) {
|
||||||
var val = undefined;
|
var val = undefined;
|
||||||
var html = '<select id="' + id + '" class="form-control selectpicker repository-dropdown" ';
|
var html = '<select id="' + id + '" class="form-control selectpicker repository-dropdown" ';
|
||||||
html += 'data-selected-value="" data-abs-min-length="2" data-live-search="true" ';
|
html += 'data-selected-value="" data-abs-min-length="2" data-live-search="true" ';
|
||||||
html += 'data-container="body" column_id="' + column_id +'">';
|
html += 'data-container="body" column_id="' + columnId +'">';
|
||||||
html += '<option value="-1"></option>';
|
html += '<option value="-1"></option>';
|
||||||
$.each(options, function(index, value) {
|
$.each(options, function(index, value) {
|
||||||
var selected = '';
|
var selected = '';
|
||||||
|
@ -254,21 +254,22 @@
|
||||||
* @param {String} name
|
* @param {String} name
|
||||||
* @param {String} column_type
|
* @param {String} column_type
|
||||||
* @param {Object} cell
|
* @param {Object} cell
|
||||||
* @param {Object} list_columns
|
* @param {Object} listColumns
|
||||||
*
|
*
|
||||||
* @returns (String)
|
* @returns (String)
|
||||||
*/
|
*/
|
||||||
function changeToFormField(object, name, column_type, cell, list_columns) {
|
function changeToFormField(object, name, column_type, cell, listColumns) {
|
||||||
var cell_id = generateInputFieldReference(name);
|
var cellId = generateInputFieldReference(name);
|
||||||
var value = cell.value || '';
|
var value = cell.value || '';
|
||||||
if (column_type === 'RepositoryListValue') {
|
if (column_type === 'RepositoryListValue') {
|
||||||
var column = _.findWhere(list_columns, { column_id: parseInt(name) });
|
var column = _.findWhere(listColumns,
|
||||||
|
{ column_id: parseInt(name, 10) });
|
||||||
var list_items = column.list_items || cell.list_items;
|
var list_items = column.list_items || cell.list_items;
|
||||||
return _listItemDropdown(list_items, value, parseInt(name), cell_id);
|
return _listItemDropdown(list_items, value, parseInt(name, 10), cellId);
|
||||||
} else if (column_type === 'RepositoryAssetValue') {
|
} else if (column_type === 'RepositoryAssetValue') {
|
||||||
return changeToInputFileField('repository_cell_file', name, value, cell_id);
|
return changeToInputFileField('repository_cell_file', name, value, cellId);
|
||||||
} else {
|
} else {
|
||||||
return changeToInputField(object, name, value, cell_id);
|
return changeToInputField(object, name, value, cellId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,12 +277,11 @@
|
||||||
* Append the change listener to file field
|
* Append the change listener to file field
|
||||||
*
|
*
|
||||||
* @param {String} type
|
* @param {String} type
|
||||||
* @param {Object} input
|
* @param {String} name
|
||||||
* @param {Object} formData
|
|
||||||
*
|
*
|
||||||
* @returns {undefined}
|
* @returns {undefined}
|
||||||
*/
|
*/
|
||||||
function _addSelectedFile(type, cell, name, formData) {
|
function addSelectedFile(type, name) {
|
||||||
var button = $('button[data-id="' +
|
var button = $('button[data-id="' +
|
||||||
generateInputFieldReference(name) +
|
generateInputFieldReference(name) +
|
||||||
'"]');
|
'"]');
|
||||||
|
@ -311,7 +311,8 @@
|
||||||
if (file) {
|
if (file) {
|
||||||
$label.text(file.name);
|
$label.text(file.name);
|
||||||
input.attr('remove', false);
|
input.attr('remove', false);
|
||||||
$label.parent().find("[data-action='removeAsset']").show();
|
$($label.closest('.repository-input-file-field')
|
||||||
|
.find('[data-action="removeAsset"]')[0]).show();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue