mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-13 08:34:49 +08:00
Merge pull request #5998 from wandji20/wb-SCI-9057
Move inline JavaScript inclusion for new and edit result table to result_tables.js [SCI-9057]
This commit is contained in:
commit
d3c0d3491c
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
|
// Apply ajax callback to form
|
||||||
function _formAjaxResultTable($form, $prevResult) {
|
function _formAjaxResultTable($form, $prevResult) {
|
||||||
$form.on('ajax:success', function(e, data) {
|
$form.on('ajax:success', function(e, data) {
|
||||||
|
@ -80,6 +87,7 @@
|
||||||
Results.expandResult($result);
|
Results.expandResult($result);
|
||||||
Comments.init();
|
Comments.init();
|
||||||
initNewResultTable();
|
initNewResultTable();
|
||||||
|
resultTableCallback();
|
||||||
});
|
});
|
||||||
$form.on('ajax:error', function(e, xhr, status, error) {
|
$form.on('ajax:error', function(e, xhr, status, error) {
|
||||||
var data = xhr.responseJSON;
|
var data = xhr.responseJSON;
|
||||||
|
@ -111,6 +119,7 @@
|
||||||
Results.toggleResultEditButtons(false);
|
Results.toggleResultEditButtons(false);
|
||||||
|
|
||||||
$('#result_name').focus();
|
$('#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">
|
<div class="well">
|
||||||
<%= form_with(model: @result, url: result_asset_path(format: :json), data: { remote: true }, html: { class: 'edit-result-asset' }) do |f| %>
|
<%= 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| %>
|
<%= f.fields_for :asset do |ff| %>
|
||||||
<span><strong><%=t "result_assets.edit.uploaded_asset" %></strong></span>
|
<span><strong><%=t "result_assets.edit.uploaded_asset" %></strong></span>
|
||||||
<p style="margin: 10px;">
|
<p style="margin: 10px;">
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
<div id="table-form" class="well">
|
<div id="table-form" class="well">
|
||||||
<%= form_with(model: @result, url: result_table_path(format: :json),
|
<%= form_with(model: @result, url: result_table_path(format: :json),
|
||||||
data: { remote: true, 'name-max-length': Constants::NAME_MAX_LENGTH }) do |f| %>
|
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">
|
<div class="editable-table">
|
||||||
<%= f.fields_for :table do |ff| %>
|
<%= f.fields_for :table do |ff| %>
|
||||||
<%= ff.hidden_field(:contents, value: ff.object.contents_utf_8, class: "hot-contents" ) %>
|
<%= ff.hidden_field(:contents, value: ff.object.contents_utf_8, class: "hot-contents" ) %>
|
||||||
|
@ -11,13 +14,12 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<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">
|
<button type="button" class="btn btn-secondary cancel-edit">
|
||||||
<%= t("general.cancel")%>
|
<%= t("general.cancel")%>
|
||||||
</button>
|
</button>
|
||||||
<%= f.button t("general.save"),
|
<%= f.button t("general.save"),
|
||||||
class: 'btn btn-primary save-result' %>
|
class: 'btn btn-primary save-result' %>
|
||||||
<%= javascript_include_tag 'results/result_tables/edit', nonce: true %>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
<div id="table-form" class="well">
|
<div id="table-form" class="well">
|
||||||
<%= form_with(model: @result, url: my_module_result_tables_path(format: :json, page: params[:page], order: params[:order]),
|
<%= 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| %>
|
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;">
|
<div class="editable-table" style="margin-bottom: 25px;">
|
||||||
<%= f.fields_for :table do |ff| %>
|
<%= f.fields_for :table do |ff| %>
|
||||||
<%= ff.hidden_field(:contents, value: ff.object.contents, class: "hot-contents" ) %>
|
<%= ff.hidden_field(:contents, value: ff.object.contents, class: "hot-contents" ) %>
|
||||||
|
@ -10,13 +13,12 @@
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</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">
|
<button type="button" class="btn btn-secondary cancel-new">
|
||||||
<%= t("general.cancel")%>
|
<%= t("general.cancel")%>
|
||||||
</button>
|
</button>
|
||||||
<%= f.button t("result_tables.new.create"),
|
<%= f.button t("result_tables.new.create"),
|
||||||
class: 'btn btn-primary save-result' %>
|
class: 'btn btn-primary save-result' %>
|
||||||
<%= javascript_include_tag 'results/result_tables/new', nonce: true %>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</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(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/number.js)
|
||||||
Rails.application.config.assets.precompile += %w(repository_columns/manage_column_partials/stock.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/new.js)
|
||||||
Rails.application.config.assets.precompile += %w(results/result_texts/edit.js)
|
Rails.application.config.assets.precompile += %w(results/result_texts/edit.js)
|
||||||
Rails.application.config.assets.precompile += %w(shared/file_preview.js)
|
Rails.application.config.assets.precompile += %w(shared/file_preview.js)
|
||||||
|
|
|
@ -1679,6 +1679,8 @@ en:
|
||||||
uploaded_asset: "Uploaded file"
|
uploaded_asset: "Uploaded file"
|
||||||
update: "Update"
|
update: "Update"
|
||||||
locked_file_error: 'This file is being edited by someone else.'
|
locked_file_error: 'This file is being edited by someone else.'
|
||||||
|
label:
|
||||||
|
name: 'Name'
|
||||||
create:
|
create:
|
||||||
success_flash: "Successfully added file result to task <strong>%{module}</strong>"
|
success_flash: "Successfully added file result to task <strong>%{module}</strong>"
|
||||||
update:
|
update:
|
||||||
|
@ -1700,10 +1702,14 @@ en:
|
||||||
head_title: "%{project} | %{module} | Add table result"
|
head_title: "%{project} | %{module} | Add table result"
|
||||||
title: "Add result to task %{module}"
|
title: "Add result to task %{module}"
|
||||||
create: "Add"
|
create: "Add"
|
||||||
|
label:
|
||||||
|
name: 'Name'
|
||||||
edit:
|
edit:
|
||||||
head_title: "%{project} | %{module} | Edit table result"
|
head_title: "%{project} | %{module} | Edit table result"
|
||||||
title: "Edit result from task %{module}"
|
title: "Edit result from task %{module}"
|
||||||
update: "Update"
|
update: "Update"
|
||||||
|
label:
|
||||||
|
name: 'Name'
|
||||||
create:
|
create:
|
||||||
success_flash: "Successfully added table result to task <strong>%{module}</strong>"
|
success_flash: "Successfully added table result to task <strong>%{module}</strong>"
|
||||||
update:
|
update:
|
||||||
|
|
Loading…
Add table
Reference in a new issue