diff --git a/app/assets/stylesheets/dmpopidor.scss b/app/assets/stylesheets/dmpopidor.scss
index 10a6e48..24862fa 100644
--- a/app/assets/stylesheets/dmpopidor.scss
+++ b/app/assets/stylesheets/dmpopidor.scss
@@ -1245,8 +1245,11 @@
text-align: center;
font-weight: bold;
color: $rust;
-
- visibility: hidden;
+ display: none;
+
+ &.valid {
+ color: $green;
+ }
}
.btn {
font-size: 20px;
@@ -1257,6 +1260,11 @@
border-color: gray;
}
}
+ .reload-button {
+ background-color: $green;
+ color: $white;
+ display: none;
+ }
&.unsaved {
background-color: $light-rust;
diff --git a/app/controllers/madmp_codebase_controller.rb b/app/controllers/madmp_codebase_controller.rb
index b2c829c..7660795 100644
--- a/app/controllers/madmp_codebase_controller.rb
+++ b/app/controllers/madmp_codebase_controller.rb
@@ -7,16 +7,17 @@
def run
fragment = MadmpFragment.find(params[:fragment_id])
script_id = params[:script_id]
- @response = fetch_run_data(fragment, script_id)
- # fragment.save_codebase_fragment(response.data, fragment.madmp_schema)
+ response = fetch_run_data(fragment, script_id)
+ fragment.save_codebase_fragment(response["data"], fragment.madmp_schema)
# EXAMPLE DATA : CODEBASE NEEDS FIXES
# file_path = Rails.root.join("config/schemas/codebase_example_data.json")
# response = JSON.load(File.open(file_path))
- # @fragment.save_codebase_fragment(response, @fragment.madmp_schema)
+ # fragment.save_codebase_fragment(response, fragment.madmp_schema)
authorize fragment
- render json: @response.to_json
+ # TODO: Needs to parse response for view
+ render json: response.to_json
end
private
diff --git a/app/javascript/views/shared/dynamic_form.js b/app/javascript/views/shared/dynamic_form.js
index 83bf5d7..86fd225 100644
--- a/app/javascript/views/shared/dynamic_form.js
+++ b/app/javascript/views/shared/dynamic_form.js
@@ -124,4 +124,28 @@
$(`table.list-${response.query_id} tbody`).html(response.html);
});
});
+
+ $(document).on('click', '.answer-run-zone .run-button', (e) => {
+ const target = $(e.target);
+ const reloadButton = target.parent().find('.reload-button');
+ const messageZone = target.parent().find('.message-zone');
+ const url = target.data('url');
+
+ $.ajax({
+ url,
+ method: 'get',
+ beforeSend: () => {
+ target.prop('disabled', true);
+ },
+ }).done(() => {
+ target.hide();
+ messageZone.show();
+ reloadButton.show();
+ });
+ });
+
+ $(document).on('click', '.answer-run-zone .reload-button', () => {
+ // eslint-disable-next-line no-restricted-globals
+ location.reload();
+ });
});
diff --git a/app/views/branded/plans/_edit_details.html.erb b/app/views/branded/plans/_edit_details.html.erb
index 89401db..bd24722 100644
--- a/app/views/branded/plans/_edit_details.html.erb
+++ b/app/views/branded/plans/_edit_details.html.erb
@@ -58,6 +58,7 @@
<%= f.button(_('Save'), class: "btn btn-default answer-save-button", type: "submit") %>
<%= d_('dmpopidor', 'You have pending changes, please save')%>
+
diff --git a/app/views/branded/shared/dynamic_form/_codebase_run.html.erb b/app/views/branded/shared/dynamic_form/_codebase_run.html.erb
index bbad3d2..18de486 100644
--- a/app/views/branded/shared/dynamic_form/_codebase_run.html.erb
+++ b/app/views/branded/shared/dynamic_form/_codebase_run.html.erb
@@ -2,18 +2,17 @@
<% label = parameters["label@#{template_locale}"]%>
<% ttip = parameters["tooltip@#{template_locale}"]%>
-
-<%= link_to label, codebase_run_url(
- nil,
- :fragment_id => fragment.id,
- :script_id => parameters["script_id"]
-), {
- :remote => true,
- :target => "_self",
- :class => "btn btn-primary",
- 'data-toggle' => "tooltip",
- 'data-placement' => 'top',
- 'data-original-title' => ttip
-} %>
-
-
\ No newline at end of file
+
+
+<%= d_('dmpopidor', 'New data have been added to your plan, please click on the "Reload" button.') %>
\ No newline at end of file
diff --git a/bin/httparty b/bin/httparty
new file mode 100644
index 0000000..3c1f839
--- /dev/null
+++ b/bin/httparty
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+#
+# This file was generated by Bundler.
+#
+# The application 'httparty' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require "pathname"
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+bundle_binstub = File.expand_path("../bundle", __FILE__)
+
+if File.file?(bundle_binstub)
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
+ load(bundle_binstub)
+ else
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
+Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
+ end
+end
+
+require "rubygems"
+require "bundler/setup"
+
+load Gem.bin_path("httparty", "httparty")
diff --git a/config/locale/dmpopidor.pot b/config/locale/dmpopidor.pot
index b8f38c0..6c4a7ce 100644
--- a/config/locale/dmpopidor.pot
+++ b/config/locale/dmpopidor.pot
@@ -549,3 +549,9 @@
msgid "Do you want to delete this element?"
msgstr ""
+
+msgid "New data have been added to your plan, please click on the \"Reload\" button."
+msgstr ""
+
+msgid "Reload"
+msgstr ""
\ No newline at end of file
diff --git a/config/locale/en_GB/dmpopidor.po b/config/locale/en_GB/dmpopidor.po
index b5a911d..62ac341 100644
--- a/config/locale/en_GB/dmpopidor.po
+++ b/config/locale/en_GB/dmpopidor.po
@@ -540,4 +540,10 @@
msgstr "Custom value: "
msgid "Do you want to delete this element?"
-msgstr "Do you want to delete this element?"
\ No newline at end of file
+msgstr "Do you want to delete this element?"
+
+msgid "New data have been added to your plan, please click on the \"Reload\" button."
+msgstr "New data have been added to your plan, please click on the \"Reload\" button."
+
+msgid "Reload"
+msgstr "Reload"
\ No newline at end of file
diff --git a/config/locale/fr_FR/dmpopidor.po b/config/locale/fr_FR/dmpopidor.po
index a9427ba..e90099e 100644
--- a/config/locale/fr_FR/dmpopidor.po
+++ b/config/locale/fr_FR/dmpopidor.po
@@ -542,4 +542,10 @@
msgstr "Valeur personnalisée : "
msgid "Do you want to delete this element?"
-msgstr "Voulez-vous vraiment supprimer cet élément ?"
\ No newline at end of file
+msgstr "Voulez-vous vraiment supprimer cet élément ?"
+
+msgid "New data have been added to your plan, please click on the \"Reload\" button."
+msgstr "De nouvelles données ont été ajoutées à votre plan, veuillez cliquer sur le bouton \"Recharger\""
+
+msgid "Reload"
+msgstr "Recharger"
\ No newline at end of file