mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-10 17:36:33 +08:00
Move inline JavaScript inclusion for new and edit result table to result_tables.js [SCI-9057]
This commit is contained in:
parent
975a197716
commit
25e6cbdbd8
8 changed files with 29 additions and 23 deletions
|
@ -64,6 +64,13 @@
|
|||
});
|
||||
}
|
||||
|
||||
// Save result table callback
|
||||
function resultTableCallback () {
|
||||
$('result-tables-buttons').on('click', '.save-result', (event) => {
|
||||
Results.processResult(event, Results.ResultTypeEnum.TABLE);
|
||||
});
|
||||
}
|
||||
|
||||
// Apply ajax callback to form
|
||||
function _formAjaxResultTable($form, $prevResult) {
|
||||
$form.on('ajax:success', function(e, data) {
|
||||
|
@ -80,6 +87,7 @@
|
|||
Results.expandResult($result);
|
||||
Comments.init();
|
||||
initNewResultTable();
|
||||
resultTableCallback();
|
||||
});
|
||||
$form.on('ajax:error', function(e, xhr, status, error) {
|
||||
var data = xhr.responseJSON;
|
||||
|
@ -111,6 +119,7 @@
|
|||
Results.toggleResultEditButtons(false);
|
||||
|
||||
$('#result_name').focus();
|
||||
resultTableCallback();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
/* global Results */
|
||||
|
||||
(function() {
|
||||
$('.edit-result-tables-buttons').on('click', '.save-result', (event) => {
|
||||
Results.processResult(event, Results.ResultTypeEnum.TABLE);
|
||||
});
|
||||
}());
|
|
@ -1,7 +0,0 @@
|
|||
/* global Results */
|
||||
|
||||
(function() {
|
||||
$('.new-result-tables-buttons').on('click', '.save-result', (event) => {
|
||||
Results.processResult(event, Results.ResultTypeEnum.TABLE);
|
||||
});
|
||||
}());
|
|
@ -1,6 +1,9 @@
|
|||
<div class="well">
|
||||
<%= form_with(model: @result, url: result_asset_path(format: :json), data: { remote: true }, html: { class: 'edit-result-asset' }) do |f| %>
|
||||
<%= f.text_field :name, style: "margin-top: 10px;" %><br />
|
||||
<div class="sci-input-container mb-4">
|
||||
<label><%= t('result_assets.edit.label.name') %></label>
|
||||
<%= f.text_field :name, class: 'sci-input-field' %>
|
||||
</div>
|
||||
<%= f.fields_for :asset do |ff| %>
|
||||
<span><strong><%=t "result_assets.edit.uploaded_asset" %></strong></span>
|
||||
<p style="margin: 10px;">
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
<div id="table-form" class="well">
|
||||
<%= form_with(model: @result, url: result_table_path(format: :json),
|
||||
data: { remote: true, 'name-max-length': Constants::NAME_MAX_LENGTH }) do |f| %>
|
||||
<%= f.text_field :name, style: "margin-top: 10px;" %><br />
|
||||
<div class="sci-input-container mb-4">
|
||||
<label><%= t('result_tables.edit.label.name') %></label>
|
||||
<%= f.text_field :name, class: 'sci-input-field' %>
|
||||
</div>
|
||||
<div class="editable-table">
|
||||
<%= f.fields_for :table do |ff| %>
|
||||
<%= ff.hidden_field(:contents, value: ff.object.contents_utf_8, class: "hot-contents" ) %>
|
||||
|
@ -11,13 +14,12 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="align-right edit-result-tables-buttons">
|
||||
<div class="align-right result-tables-buttons">
|
||||
<button type="button" class="btn btn-secondary cancel-edit">
|
||||
<%= t("general.cancel")%>
|
||||
</button>
|
||||
<%= f.button t("general.save"),
|
||||
class: 'btn btn-primary save-result' %>
|
||||
<%= javascript_include_tag 'results/result_tables/edit', nonce: true %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
<div id="table-form" class="well">
|
||||
<%= form_with(model: @result, url: my_module_result_tables_path(format: :json, page: params[:page], order: params[:order]),
|
||||
data: { remote: true, 'name-max-length': Constants::NAME_MAX_LENGTH }) do |f| %>
|
||||
<%= f.text_field :name, style: "margin-top: 10px;" %><br />
|
||||
<div class="sci-input-container mb-4">
|
||||
<label><%= t('result_tables.new.label.name') %></label>
|
||||
<%= f.text_field :name, class: 'sci-input-field' %>
|
||||
</div>
|
||||
<div class="editable-table" style="margin-bottom: 25px;">
|
||||
<%= f.fields_for :table do |ff| %>
|
||||
<%= ff.hidden_field(:contents, value: ff.object.contents, class: "hot-contents" ) %>
|
||||
|
@ -10,13 +13,12 @@
|
|||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="align-right new-result-tables-buttons">
|
||||
<div class="align-right result-tables-buttons">
|
||||
<button type="button" class="btn btn-secondary cancel-new">
|
||||
<%= t("general.cancel")%>
|
||||
</button>
|
||||
<%= f.button t("result_tables.new.create"),
|
||||
class: 'btn btn-primary save-result' %>
|
||||
<%= javascript_include_tag 'results/result_tables/new', nonce: true %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -108,8 +108,6 @@ Rails.application.config.assets.precompile += %w(users/registrations/new_with_pr
|
|||
Rails.application.config.assets.precompile += %w(team_zip_exports/load_handson.js)
|
||||
Rails.application.config.assets.precompile += %w(repository_columns/manage_column_partials/number.js)
|
||||
Rails.application.config.assets.precompile += %w(repository_columns/manage_column_partials/stock.js)
|
||||
Rails.application.config.assets.precompile += %w(results/result_tables/new.js)
|
||||
Rails.application.config.assets.precompile += %w(results/result_tables/edit.js)
|
||||
Rails.application.config.assets.precompile += %w(results/result_texts/new.js)
|
||||
Rails.application.config.assets.precompile += %w(results/result_texts/edit.js)
|
||||
Rails.application.config.assets.precompile += %w(shared/file_preview.js)
|
||||
|
|
|
@ -1679,6 +1679,8 @@ en:
|
|||
uploaded_asset: "Uploaded file"
|
||||
update: "Update"
|
||||
locked_file_error: 'This file is being edited by someone else.'
|
||||
label:
|
||||
name: 'Name'
|
||||
create:
|
||||
success_flash: "Successfully added file result to task <strong>%{module}</strong>"
|
||||
update:
|
||||
|
@ -1700,10 +1702,14 @@ en:
|
|||
head_title: "%{project} | %{module} | Add table result"
|
||||
title: "Add result to task %{module}"
|
||||
create: "Add"
|
||||
label:
|
||||
name: 'Name'
|
||||
edit:
|
||||
head_title: "%{project} | %{module} | Edit table result"
|
||||
title: "Edit result from task %{module}"
|
||||
update: "Update"
|
||||
label:
|
||||
name: 'Name'
|
||||
create:
|
||||
success_flash: "Successfully added table result to task <strong>%{module}</strong>"
|
||||
update:
|
||||
|
|
Loading…
Reference in a new issue