Skip to content

Commit 706adef

Browse files
authored
Merge pull request #444 from DigitalCurationCentre/issue_431
Issue #431
2 parents c84329c + 51acde7 commit 706adef

File tree

14 files changed

+120
-304
lines changed

14 files changed

+120
-304
lines changed

app/views/devise/registrations/edit.html.erb

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,3 @@
115115

116116
<% end %>
117117
</div>
118-
119-
120-
<!-- alert for the default template-->
121-
<div id="unlink-institutional-credentials-dialog" data-container="body" data-backdrop="static" class="modal hide fade">
122-
<div class="modal-header">
123-
<h3><%= _('Unlink institutional credentials alert') %></h3>
124-
</div>
125-
<div class="modal-body">
126-
<%= raw _('<p>You are about to unlink %{application_name} of your institutional credentials, would you like to continue?</p>') % { :application_name => user_shibboleth_omniauth_authorize_path } %>
127-
</div>
128-
<div class="modal-footer">
129-
<a href="#" id="unlink-shibboleth-cancelled" class="btn"><%= _('Cancel') %></a>
130-
<a href="#" id="unlink-shibboleth-confirmed" class="btn btn-primary"><%= _('Unlink account') %></a>
131-
</div>
132-
</div>

app/views/plans/_plan_details.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<% javascript('plans/edit.js') %>
12
<!-- Project title = default title is the template title plus date of creation -->
23
<div class="dmp_details_body">
34

@@ -77,7 +78,7 @@
7778

7879
<!-- edit plan button -->
7980
<div class="div_right">
80-
<a href='#' class='btn btn-primary show-edit-toggle'><%= _('Edit plan details') %></a>
81+
<button class="btn btn-primary show-edit-toggle"><%= _('Edit plan details') %></button>
8182
</div>
8283

8384
<!-- display plan details -->

app/views/plans/share.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<%- model_class = Plan -%>
2-
2+
<% javascript('plans/share.js') %>
33
<!-- render the project title -->
44
<%= render :partial => "plan_title", locals: {plan: @plan} %>
55

@@ -35,7 +35,7 @@
3535
<% else %>
3636
<%= form_for role, url: {controller: :roles, action: :update, id: role.id }, html: {method: :put} do |f| %>
3737
<fieldset>
38-
<%= f.select :access_level, {"#{_('Co-owner')}": 3, "#{_('Editor')}": 2, "#{_('Read only')}": 1}, {}, {id: "#{role.id}-can-edit", class: "toggle-existing-user-access has-tooltip", 'data-toggle': "tooltip", 'title': _('Editors can contribute to plans. Co-owners have additional rights to edit plan details and control access.') } %>
38+
<%= f.select :access_level, {"#{_('Co-owner')}": 3, "#{_('Editor')}": 2, "#{_('Read only')}": 1}, {}, {id: "#{role.id}-can-edit", class: "toggle-access-level has-tooltip", 'data-toggle': "tooltip", 'title': _('Editors can contribute to plans. Co-owners have additional rights to edit plan details and control access.') } %>
3939
</fieldset>
4040
<% end %>
4141
<% end %>

app/views/question_options/_option_fields.html.erb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
<td class="small"><%= f.number_field :number, in: 1..20, class: "number_field option"%></td>
44
<td class="medium"><%= f.text_field :text, as: :string, class: "small_text_field" %></td>
55
<td class="small"><%= f.check_box :is_default %></td>
6-
<td class="small"><%= f.hidden_field :_destroy %><span class="remove-option"><%= _('Remove') %></span></td>
6+
<td class="small">
7+
<%= f.hidden_field :_destroy %>
8+
<span class="remove-option"><%= _('Remove') %></span>
9+
</td>
710
</tr>

app/views/shared/_register_form.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<% javascript "shared/register_form.js" %>
1+
<% javascript('shared/register_form.js') %>
22

33
<%= form_for(resource, :as => "user", :url => registration_path("user"), :htmlb => {:autocomplete =>"off"}, :html => {class: "roadmap-form"}) do |f| %>
44
<ul>

config/application.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ class Application < Rails::Application
6868
config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif *ico)
6969
config.assets.precompile += %w(*mp4 *webm *ogg *ogv *swf)
7070

71-
config.assets.precompile += %w(plans.js)
72-
config.assets.precompile += %w(projects.js)
71+
config.assets.precompile += %w(plans.js)
7372
config.assets.precompile += %w(jquery.placeholder.js)
7473
config.assets.precompile += %w(jquery.tablesorter.js)
7574
config.assets.precompile += %w(jquery-accessible-autocomplet-list-aria.js)
@@ -80,10 +79,13 @@ class Application < Rails::Application
8079

8180
config.assets.precompile += %w(roadmap-form.scss)
8281
config.assets.precompile += %w(plans/new_plan.js)
82+
config.assets.precompile += %w(plans/edit.js)
83+
config.assets.precompile += %w(plans/share.js)
8384
config.assets.precompile += %w(contacts/new_contact.js)
8485
config.assets.precompile += %w(shared/register_form.js)
8586
config.assets.precompile += %w(answers/status.js)
8687
config.assets.precompile += %w(notes/index.js)
88+
config.assets.precompile += %w(bootstrap_listeners.js)
8789

8890
config.autoload_paths += %W(#{config.root}/lib)
8991
config.action_controller.include_all_helpers = true

lib/assets/javascripts/admin.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,45 @@
77

88

99
$( document ).ready(function() {
10+
/*----------------
11+
Listener for removing a question_option for option_based questions
12+
Note the usage of event-delegation approach through the presence of the selector (e.g. .remove-option) which means the handler
13+
is ONLY called when the event occurs at .remove-option and has the advantage of processing events from descendant elements (e.g. tr class="options_content")
14+
that are added to the document at a later time
15+
------------------*/
16+
$('.options_table').on('click','.remove-option', function(e){
17+
e.preventDefault();
18+
$(this).prev().val(true);
19+
$(this).closest('.options_content').hide();
20+
});
21+
/*----------------
22+
Listener for adding a question_option for option_based questions
23+
------------------*/
24+
$(".add-option").click(function(e){
25+
e.preventDefault();
1026

27+
var tbl = $(this).parent().find("table.options_table > tbody.options_tbody"),
28+
last = tbl.find("tr:last"),
29+
clone = last.clone();
30+
nbr = parseInt(last.find(".number_field").val());
31+
32+
// Update the input field names and ids
33+
clone.find("input").each(function(index){
34+
$(this).prop("id", $(this).prop("id").replace(/_\d+_/g, "_" + nbr + "_"));
35+
$(this).prop("name", $(this).prop("name").replace(/\[\d+\]/g, "[" + nbr + "]"));
36+
});
37+
38+
// Remove the hidden class and make sure the new row is not marked for removal
39+
clone.removeClass('hidden');
40+
clone.find("[id$=" + nbr + "__destroy]").val(false);
41+
42+
// Default the other values
43+
clone.find("[id$=" + nbr + "_number]").val("" + (nbr + 1));
44+
clone.find("[id$=" + nbr + "_text]").val("");
45+
clone.find("[id$=" + nbr + "_is_default]").prop("checked", false);
46+
47+
last.after(clone);
48+
});
1149
if($('.in').length > 0) {
1250
if ($('.in .current_question').length > 0) {
1351
$(document.body).animate({

lib/assets/javascripts/application.js

Lines changed: 1 addition & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -22,173 +22,4 @@
2222
//= require_tree ./locale
2323
//= require gettext/all
2424
//= require jquery-accessible-autocomplet-list-aria.js
25-
26-
27-
$( document ).ready(function() {
28-
29-
$(function(){
30-
$('.dropdown-toggle').dropdown()
31-
});
32-
33-
$('.accordion-body').on('show', function() {
34-
var plus = $(this).parent().children(".accordion-heading").children(".accordion-toggle").children(".icon-plus").removeClass("icon-plus").addClass("icon-minus");
35-
}).on('hide', function(){
36-
var minus = $(this).parent().children(".accordion-heading").children(".accordion-toggle").children(".icon-minus").removeClass("icon-minus").addClass("icon-plus");
37-
});
38-
39-
//accordion home page
40-
$('.accordion-home').on('show', function() {
41-
var plus = $(this).parent().find(".plus-laranja").removeClass("plus-laranja").addClass("minus-laranja");
42-
}).on('hide', function(){
43-
var minus = $(this).parent().find(".minus-laranja").removeClass("minus-laranja").addClass("plus-laranja");
44-
});
45-
46-
//accordion project details page when project has more than 1 plan
47-
$('.accordion-project').on('show', function() {
48-
var plus = $(this).parent().children(".accordion-heading").find(".plus-laranja").removeClass("plus-laranja").addClass("minus-laranja");
49-
}).on('hide', function(){
50-
var minus = $(this).parent().children(".accordion-heading").find(".minus-laranja").removeClass("minus-laranja").addClass("plus-laranja");
51-
});
52-
53-
$('.export-format-selection').click(function(e){
54-
e.preventDefault();
55-
if($(this).val() == 'pdf'){
56-
$('#pdf-format-options').show();
57-
}else{
58-
$('#pdf-format-options').hide();
59-
}
60-
});
61-
62-
//$('#3-or-4-splash').modal();
63-
64-
$('.typeahead').select2({
65-
width: "element",
66-
allowClear: true
67-
});
68-
69-
$(".help").popover();
70-
71-
$('.has-tooltip').tooltip({
72-
placement: "right",
73-
trigger: "focus"
74-
});
75-
76-
$(".show-edit-toggle").click(function (e) {
77-
e.preventDefault();
78-
79-
$(".edit-plan-details").toggle();
80-
$(".show-plan-details").toggle();
81-
});
82-
83-
$(".toggle-existing-user-access").change(function(){
84-
$(this).closest("form").submit();
85-
});
86-
87-
$('#user_organisation_id').on("change", function(e) {
88-
e.preventDefault();
89-
var selected_org = $(this).select2("val");
90-
var other_orgs = $("#other-organisation-name").attr("data-orgs").split(",");
91-
var index = $.inArray(selected_org, other_orgs);
92-
if (index > -1) {
93-
$("#other-organisation-name").show();
94-
$("#user_other_organisation").focus();
95-
}
96-
else {
97-
$("#other-organisation-name").hide();
98-
}
99-
});
100-
101-
$("#other-org-link > a").click(function(e){
102-
e.preventDefault();
103-
var other_org = $("#other-organisation-name").attr("data-orgs").split(",");
104-
$("#user_organisation_id").select2("val", other_org);
105-
$("#other-org-link").hide();
106-
$("#user_organisation_id").change();
107-
});
108-
109-
//alert dialog for unlink Shibbileth account
110-
$("#unlink-institutional-credentials-dialog").on("show", function(){
111-
$('.select2-choice').hide();
112-
});
113-
114-
$("#unlink-shibboleth-cancelled").click(function (){
115-
$("#unlink-institutional-credentials-dialog").modal("hide");
116-
$('.select2-choice').show();
117-
});
118-
119-
$("#unlink-shibboleth-confirmed").click(function (){
120-
$("#unlink_flag").val('true');
121-
$("#edit_user").submit();
122-
123-
});
124-
125-
//Question Options
126-
// ---------------------------------------------------------------------------
127-
$(".options_table").on("click", ".remove-option", function(e){
128-
e.preventDefault();
129-
130-
// Mark the option for removal
131-
$($(this).siblings()[0]).val(true);
132-
133-
// Hide the entire table row and the associated hidden field for the item
134-
$(this).parent().parent().addClass('hidden');
135-
});
136-
137-
$(".add-option").click(function(e){
138-
e.preventDefault();
139-
140-
var tbl = $(this).parent().find("table.options_table > tbody.options_tbody"),
141-
last = tbl.find("tr:last"),
142-
clone = last.clone();
143-
nbr = parseInt(last.find(".number_field").val());
144-
145-
// Update the input field names and ids
146-
clone.find("input").each(function(index){
147-
$(this).prop("id", $(this).prop("id").replace(/_\d+_/g, "_" + nbr + "_"));
148-
$(this).prop("name", $(this).prop("name").replace(/\[\d+\]/g, "[" + nbr + "]"));
149-
});
150-
151-
// Remove the hidden class and make sure the new row is not marked for removal
152-
clone.removeClass('hidden');
153-
clone.find("[id$=" + nbr + "__destroy]").val(false);
154-
155-
// Default the other values
156-
clone.find("[id$=" + nbr + "_number]").val("" + (nbr + 1));
157-
clone.find("[id$=" + nbr + "_text]").val("");
158-
clone.find("[id$=" + nbr + "_is_default]").prop("checked", false);
159-
160-
last.after(clone);
161-
});
162-
163-
/*$('#continue-to-new').click(function(e){
164-
var destination = $(this).attr("href");
165-
var n = destination.lastIndexOf('=');
166-
destination = decodeURIComponent(destination.substring(n + 1));
167-
$.post('splash_logs', {destination: destination} );
168-
$("#3-or-4-splash").modal('hide');
169-
return false;
170-
});*/
171-
172-
});
173-
174-
// ---------------------------------------------------------------------------
175-
function selectItemsFromJsonArray(array, selector, array_of_values, callback){
176-
var out = [];
177-
178-
if(!Array.isArray(array_of_values)){
179-
array_of_values = [array_of_values];
180-
}
181-
182-
for(var i = 0; i < array.length; i++){
183-
if(array_of_values.indexOf('' + array[i][selector]) >= 0){
184-
out.push(array[i]);
185-
}
186-
}
187-
188-
var selectItemsFromJsonArrayInterval = setInterval(function(){
189-
if(i >= array.length){
190-
clearInterval(selectItemsFromJsonArrayInterval);
191-
callback(out);
192-
}
193-
}, 50);
194-
}
25+
//= require bootstrap_listeners.js
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
$(document).ready(function(){
2+
$('.accordion-body').on('show.bs.collapse', function(){
3+
$(this).parent().find('.icon-plus').removeClass('icon-plus').addClass('icon-minus');
4+
}).on('hide.bs.collapse', function(){
5+
$(this).parent().find('.icon-minus').removeClass('icon-minus').addClass('icon-plus');
6+
});
7+
$('.accordion-home').on('show', function() {
8+
$(this).parent().find('.plus-laranja').removeClass('plus-laranja').addClass('minus-laranja');
9+
}).on('hide', function(){
10+
$(this).parent().find('.minus-laranja').removeClass('minus-laranja').addClass('plus-laranja');
11+
});
12+
$('.accordion-project').on('show', function() {
13+
$(this).parent().find('.plus-laranja').removeClass('plus-laranja').addClass('minus-laranja');
14+
}).on('hide', function(){
15+
$(this).parent().find('.minus-laranja').removeClass('minus-laranja').addClass('plus-laranja');
16+
});
17+
// Initialises all tooltips present on a page
18+
$('.has-tooltip').tooltip({
19+
placement: "right",
20+
trigger: "focus"
21+
});
22+
$(".help").popover();
23+
});

lib/assets/javascripts/export_configure.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,15 @@ $(document).ready(function() {
105105
});
106106
});
107107
});
108+
/*----------------
109+
Listener for select that displays the formatting options (e.g. csv, html, pdf, txt, etc.)
110+
------------------*/
111+
$('.export-format-selection').click(function(e){
112+
e.preventDefault();
113+
if($(this).val() === 'pdf'){
114+
$('#pdf-format-options').show();
115+
}else{
116+
$('#pdf-format-options').hide();
117+
}
118+
});
108119
});

0 commit comments

Comments
 (0)