- <%= f.label :remember_me, raw("#{f.check_box :remember_me}#{_('Remember email')}") %>
+ <%= label_tag 'remember_email', raw("#{check_box_tag 'remember_email'}#{_('Remember email')}") %>
<%= f.label(:password, _('Password'), class: 'control-label') %>
diff --git a/app/views/static_pages/termsuse.html.erb b/app/views/static_pages/termsuse.html.erb
index 3d4ae16..09acf04 100644
--- a/app/views/static_pages/termsuse.html.erb
+++ b/app/views/static_pages/termsuse.html.erb
@@ -7,14 +7,12 @@
-
The <%= link_to 'Digital Curation Centre', 'https://dmponline.dcc.ac.uk/' %> (DCC) and the <%= link_to 'California Digital Library', 'http://www.cdlib.org/' %>
+
The <%= link_to 'Digital Curation Centre', 'https://dmponline.dcc.ac.uk/' %> (DCC) and <%= link_to 'California Digital Library', 'http://www.cdlib.org/' %>
<%= _("(CDL) are consortia supported by the University of Edinburgh and the University of California, respectively. Our primary constituency is the research community. We provide services to the UK, US and international higher education sector. ") %>
-
<%= _(" %{application_name} ") % {:application_name => Rails.configuration.branding[:application][:name]} %>
+
<%= _('DMPRoadmap') %>
-
<%= _("DMPRoadmap ('the tool', 'the system') is a tool developed by the DCC and CDL as a shared resource for the research community. It is hosted at ") %>
-
- <%= _(" %{organisation_name} ") % { :organisation_name => Rails.configuration.branding[:organisation][:name]} %>
+
<%= _("DMPRoadmap ('the tool', 'the system') is a tool developed by the DCC and CDL as a shared resource for the research community. It is hosted at CDL by the University of California Curation Center.") %>
<%= raw _("
Your personal details and consent notice
@@ -36,7 +34,7 @@
Cookies
-
Please note that %{application_name} uses Cookies. Further information about Cookies and how we use them is available on the main DCC website.
+
Please note that DMPRoadmap uses Cookies. Further information about Cookies and how we use them is available on the main DCC website.
Third party APIs
@@ -44,7 +42,7 @@
Revisions
-
This statement was last revised on October 5, 2017 and may be revised at any time. Use of the tool indicates that you understand and agree to these terms and conditions.
" )%>
+
This statement was last revised on October 5, 2017 and may be revised at any time. Use of the tool indicates that you understand and agree to these terms and conditions.
" ) %>
\ No newline at end of file
diff --git a/config/application.rb b/config/application.rb
index e19efb1..477c57e 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -90,5 +90,8 @@
# is_test - (NOT advisable because test plans are excluded from statistics)
# privately_visible - Only the owner and people they invite can access the plan
config.default_plan_visibility = 'privately_visible'
+
+ # The percentage of answered questions needed to enable the plan visibility section of the Share plan page
+ config.default_plan_percentage_answered = 50.00
end
end
diff --git a/db/migrate/20171013152425_add_principal_investigator_phone_to_plans.rb b/db/migrate/20171013152425_add_principal_investigator_phone_to_plans.rb
new file mode 100644
index 0000000..dc39e45
--- /dev/null
+++ b/db/migrate/20171013152425_add_principal_investigator_phone_to_plans.rb
@@ -0,0 +1,5 @@
+class AddPrincipalInvestigatorPhoneToPlans < ActiveRecord::Migration
+ def change
+ add_column :plans, :principal_investigator_phone, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 925db70..a15cd65 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20170719114516) do
+ActiveRecord::Schema.define(version: 20171013152425) do
create_table "annotations", force: :cascade do |t|
t.integer "question_id", limit: 4
@@ -228,6 +228,7 @@
t.string "data_contact_email", limit: 255
t.string "data_contact_phone", limit: 255
t.string "principal_investigator_email", limit: 255
+ t.string "principal_investigator_phone"
end
add_index "plans", ["template_id"], name: "index_plans_on_template_id", using: :btree
diff --git a/lib/assets/javascripts/utils/ariatiseForm.js b/lib/assets/javascripts/utils/ariatiseForm.js
index 2db61b3..1ecb370 100644
--- a/lib/assets/javascripts/utils/ariatiseForm.js
+++ b/lib/assets/javascripts/utils/ariatiseForm.js
@@ -16,6 +16,13 @@
be run if the field has a value.
Example: `
`
+ Validation with a custom error message
+ ------------------------
+ To add a custom error message to a field's validation (default messages can be found
+ in the constants.js file) just add a 'data-validation-error' attribute to the field.
+ Example: `
`
+
Validation for radio buttons
------------------------
To add validation to a set of `radio` buttons, use the rules listed above,
@@ -95,6 +102,8 @@
switch (type) {
case 'text':
return validator.isValidText(value);
+ case 'textarea':
+ return validator.isValidText(value);
case 'number':
return validator.isValidNumber(value);
case 'email':
@@ -114,6 +123,8 @@
switch (type) {
case 'text':
return constants.VALIDATION_MESSAGE_TEXT;
+ case 'textarea':
+ return constants.VALIDATION_MESSAGE_TEXT;
case 'number':
return constants.VALIDATION_MESSAGE_NUMBER;
case 'email':
diff --git a/lib/assets/javascripts/utils/notificationHelper.js b/lib/assets/javascripts/utils/notificationHelper.js
new file mode 100644
index 0000000..bb40b9b
--- /dev/null
+++ b/lib/assets/javascripts/utils/notificationHelper.js
@@ -0,0 +1,28 @@
+import { isString, isObject } from './isType';
+/*
+ Helpers that will display the specified message in in the notification
+ area at the top of the page
+*/
+export const renderNotice = (msg) => {
+ const notificationArea = $('#notification-area');
+
+ if (isString(msg) && isObject(notificationArea)) {
+ notificationArea.removeClass('alert-warning').addClass('alert-info');
+ notificationArea.find('i, span').remove();
+ notificationArea.append(`
+
${msg}`);
+ notificationArea.removeClass('hide');
+ }
+};
+
+export const renderAlert = (msg) => {
+ const notificationArea = $('#notification-area');
+
+ if (isString(msg) && isObject(notificationArea)) {
+ notificationArea.removeClass('alert-info').addClass('alert-warning');
+ notificationArea.find('i, span').remove();
+ notificationArea.append(`
+
${msg}`);
+ notificationArea.removeClass('hide');
+ }
+};
diff --git a/lib/assets/javascripts/views/answers/status.js b/lib/assets/javascripts/views/answers/status.js
index 55e3aa0..822a4e7 100644
--- a/lib/assets/javascripts/views/answers/status.js
+++ b/lib/assets/javascripts/views/answers/status.js
@@ -66,7 +66,7 @@
});
});
// Listener for input or select field
- $('.question-form').on('change', 'form.answer fieldset input, form.answer fieldset select', (e) => {
+ $('.form-answer').on('change', 'input, select', (e) => {
hideNotAnswered(e.target);
const id = questionId(e.target);
if (!debounceMap[id]) {
diff --git a/lib/assets/javascripts/views/notes/index.js b/lib/assets/javascripts/views/notes/index.js
index 1259cfe..4826544 100644
--- a/lib/assets/javascripts/views/notes/index.js
+++ b/lib/assets/javascripts/views/notes/index.js
@@ -2,7 +2,28 @@
import { isObject, isString } from '../../utils/isType';
$(() => {
- let currentViewSelector = null;
+ const defaultViewSelector = questionId => `#note_new${questionId}`;
+ const currentViewSelector = {};
+ /*
+ currentViewSelector represents a map where each key is the question id and
+ each value is the note view selector currently displayed. The value for a key
+ should be one of:
+ - #note_new${questionId}
+ - #note_show${note.id}
+ - #note_edit${note.id}
+ - #note_archive${note.id}
+ */
+ const getCurrentViewSelector = questionId => currentViewSelector[questionId];
+ const putCurrentViewSelector =
+ (questionId, value) => {
+ currentViewSelector[questionId] = value;
+ };
+ const initialiseCurrentViewSelector = () => {
+ $('.note_new').each((i, e) => {
+ const questionId = $(e).attr('data-question-id');
+ putCurrentViewSelector(questionId, defaultViewSelector(questionId));
+ });
+ };
const success = (data) => {
if (isObject(data) &&
isObject(data.notes) &&
@@ -11,76 +32,141 @@
isObject(data.title) &&
isString(data.title.id) &&
isString(data.title.html)) {
- clean(); // eslint-disable-line no-use-before-define
$(`#notes-${data.notes.id}`).html(data.notes.html);
$(`#notes-title-${data.title.id}`).html(data.title.html);
- initOrReload(); // eslint-disable-line no-use-before-define
}
+ clean(); // eslint-disable-line no-use-before-define
+ initOrReload(); // eslint-disable-line no-use-before-define
};
const error = () => {
// TODO adequate error handling for network error
};
const getAction = jQueryForm => jQueryForm.attr('action');
const getMethod = jQueryForm => jQueryForm.attr('method');
- const noteNewLinkHandler = (e) => {
- $(e.target).css('visibility', 'hidden');
- if (currentViewSelector) {
- $(currentViewSelector).hide();
+ const destroyCurrentViewEditor = (el) => {
+ const id = $(el).find('textarea').attr('id');
+ if (id) {
+ Tinymce.destroyEditorById(id);
}
- currentViewSelector = $(e.target).attr('href');
- $(currentViewSelector).show();
};
- const noteOtherLinkHandler = (e) => {
- $(e.target).closest('.notes').find('.note_new_link').css('visibility', 'visible');
- if (currentViewSelector) {
- $(currentViewSelector).hide();
+ const noteNewLinkHandler = (e) => {
+ const source = e.target;
+ const target = $(source).attr('href');
+ const questionId = $(target).attr('data-question-id');
+ const viewSelectorSelected = getCurrentViewSelector(questionId);
+ if (viewSelectorSelected !== target) {
+ $(viewSelectorSelected)
+ .hide({ complete: () => destroyCurrentViewEditor($(viewSelectorSelected)) });
+ putCurrentViewSelector(questionId, target);
+ $(source).css('visibility', 'hidden');
+ $(target).show();
+ Tinymce.init({ selector: `#${$(target).find('textarea').attr('id')}` });
}
- currentViewSelector = $(e.target).attr('href');
- $(currentViewSelector).show();
+ };
+ const noteShowLinkHandler = (e) => {
+ const source = e.target;
+ const target = $(source).attr('href');
+ const questionId = $(target).attr('data-question-id');
+ const viewSelectorSelected = getCurrentViewSelector(questionId);
+ if (viewSelectorSelected !== target) {
+ $(viewSelectorSelected)
+ .hide({ complete: () => destroyCurrentViewEditor($(viewSelectorSelected)) });
+ putCurrentViewSelector(questionId, target);
+ $(source).closest('.notes').find('.note_new_link').css('visibility', 'visible');
+ $(target).show();
+ }
+ };
+ const noteEditLinkHandler = (e) => {
+ const source = e.target;
+ const target = $(source).attr('href');
+ const questionId = $(target).attr('data-question-id');
+ const viewSelectorSelected = getCurrentViewSelector(questionId);
+ if (viewSelectorSelected !== target) {
+ $(viewSelectorSelected)
+ .hide({ complete: () => destroyCurrentViewEditor($(viewSelectorSelected)) });
+ putCurrentViewSelector(questionId, target);
+ $(source).closest('.notes').find('.note_new_link').css('visibility', 'hidden');
+ $(target).show();
+ Tinymce.init({ selector: `#${$(target).find('textarea').attr('id')}` });
+ }
+ };
+ const noteArchiveLinkHandler = (e) => {
+ const source = e.target;
+ const target = $(source).attr('href');
+ const questionId = $(target).attr('data-question-id');
+ const viewSelectorSelected = getCurrentViewSelector(questionId);
+ if (viewSelectorSelected !== target) {
+ $(viewSelectorSelected)
+ .hide({ complete: () => destroyCurrentViewEditor($(viewSelectorSelected)) });
+ putCurrentViewSelector(questionId, target);
+ $(source).closest('.notes').find('.note_new_link').css('visibility', 'hidden');
+ $(target).show();
+ }
};
const newEditNoteHandler = (e) => {
e.preventDefault();
+ const source = e.target;
const jQueryForm = $(e.target).closest('form');
const formElements = jQueryForm.serializeArray();
const noteText = formElements.find(el => el.name === 'note[text]');
- noteText.value = Tinymce.findEditorById($(e.target).closest('form').find('[name="note[text]"]').attr('id')).getContent();
+ const id = $(source).closest('form').find('[name="note[text]"]').attr('id');
+ const questionId = $(source).closest('.note_new').attr('data-question-id') ||
+ $(source).closest('.note_edit').attr('data-question-id');
+ noteText.value = Tinymce.findEditorById(id).getContent();
$.ajax({
method: getMethod(jQueryForm),
url: getAction(jQueryForm),
data: formElements,
- }).done(success, error);
+ }).done((data) => {
+ Tinymce.destroyEditorById(id);
+ success(data);
+ putCurrentViewSelector(questionId, defaultViewSelector(questionId));
+ }, error);
};
const archiveNoteDestroyHandler = (e) => {
e.preventDefault();
- const jQueryForm = $(e.target).closest('form');
+ const source = e.target;
+ const jQueryForm = $(source).closest('form');
const formElements = jQueryForm.serializeArray();
+ const questionId = $(source).closest('.note_archive').attr('data-question-id');
$.ajax({
method: getMethod(jQueryForm),
url: getAction(jQueryForm),
data: formElements,
- }).done(success, error);
+ }).done((data) => {
+ success(data);
+ putCurrentViewSelector(questionId, defaultViewSelector(questionId));
+ }, error);
};
- const archiveNoteCancelHandler = () => {
- if (currentViewSelector) {
- $(currentViewSelector).hide();
- }
+ const noteCancelHandler = (e) => {
+ const source = e.target;
+ const questionId = $(source).closest('.note_edit').attr('data-question-id') ||
+ $(source).closest('.note_archive').attr('data-question-id');
+ const viewSelectorSelected = getCurrentViewSelector(questionId);
+ $(viewSelectorSelected)
+ .hide({ complete: () => destroyCurrentViewEditor($(viewSelectorSelected)) });
+ $(e.target).closest('.notes').find('.note_new_link').css('visibility', 'visible');
+ putCurrentViewSelector(questionId, null);
};
const eventHandlers = ({ attachment = 'off' }) => {
$('.notes .note_new_link')[attachment]('click', noteNewLinkHandler);
- $('.notes .note_show_link, .notes .note_edit_link, .notes .note_archive_link')[attachment]('click', noteOtherLinkHandler);
+ $('.notes .note_show_link')[attachment]('click', noteShowLinkHandler);
+ $('.notes .note_edit_link')[attachment]('click', noteEditLinkHandler);
+ $('.notes .note_archive_link')[attachment]('click', noteArchiveLinkHandler);
$('.new_note')[attachment]('submit', newEditNoteHandler);
$('.edit_note')[attachment]('submit', newEditNoteHandler);
+ $('.edit_note button[type="button"]')[attachment]('click', noteCancelHandler);
$('.archive_note')[attachment]('submit', archiveNoteDestroyHandler);
- $('.archive_note button[type="button"]')[attachment]('click', archiveNoteCancelHandler);
+ $('.archive_note button[type="button"]')[attachment]('click', noteCancelHandler);
};
const initOrReload = () => {
Tinymce.init({ selector: '.note' });
eventHandlers({ attachment: 'on' });
};
const clean = () => {
- currentViewSelector = null;
eventHandlers({ attachment: 'off' });
Tinymce.destroyEditorsByClassName('note');
};
initOrReload();
+ initialiseCurrentViewSelector();
});
diff --git a/lib/assets/javascripts/views/orgs/shibboleth_ds.js b/lib/assets/javascripts/views/orgs/shibboleth_ds.js
index b113489..f186b93 100644
--- a/lib/assets/javascripts/views/orgs/shibboleth_ds.js
+++ b/lib/assets/javascripts/views/orgs/shibboleth_ds.js
@@ -11,11 +11,11 @@
$('#show_list').click((e) => {
e.preventDefault();
- if ($('#full_list').is('.hide')) {
- $('#full_list').show();
+ if ($('#full_list').is('.hidden')) {
+ $('#full_list').removeClass('hidden').attr('aria-hidden', 'false');
$(e.currentTarget).html(SHIBBOLETH_DISCOVERY_SERVICE_HIDE_LIST);
} else {
- $('#full_list').hide();
+ $('#full_list').addClass('hidden').attr('aria-hidden', 'true');
$(e.currentTarget).html(SHIBBOLETH_DISCOVERY_SERVICE_SHOW_LIST);
}
});
diff --git a/lib/assets/javascripts/views/plans/download.js b/lib/assets/javascripts/views/plans/download.js
index 2f5af98..621525d 100644
--- a/lib/assets/javascripts/views/plans/download.js
+++ b/lib/assets/javascripts/views/plans/download.js
@@ -1,6 +1,13 @@
$(() => {
+ // Add a target="_blank" to the form when PDF or HTML are selected
// Hide the PDF Formatting section if 'pdf' is not the desired format
- $('select#format').on('change', (e) => {
+ $('#download_form select#format').on('change', (e) => {
+ if ($(e.currentTarget).val() === 'pdf' || $(e.currentTarget).val() === 'html') {
+ $('#download_form').attr('target', '_blank');
+ } else {
+ $('#download_form').removeAttr('target');
+ }
+
if ($(e.currentTarget).val() === 'pdf') {
$('#pdf-formatting').show();
} else {
diff --git a/lib/assets/javascripts/views/plans/edit_details.js b/lib/assets/javascripts/views/plans/edit_details.js
index 84f3535..fd04772 100644
--- a/lib/assets/javascripts/views/plans/edit_details.js
+++ b/lib/assets/javascripts/views/plans/edit_details.js
@@ -7,4 +7,17 @@
$('#plan_visibility').val($(this).is(':checked') ? 'is_test' : 'privately_visible');
});
ariatiseForm({ selector: '.edit_plan' });
+
+ const showHideDataContact = (el) => {
+ if ((el).is(':checked')) {
+ $('div.data-contact').fadeOut();
+ } else {
+ $('div.data-contact').fadeIn();
+ }
+ };
+
+ $('#show_data_contact').click((e) => {
+ showHideDataContact($(e.currentTarget));
+ });
+ showHideDataContact($('#show_data_contact'));
});
diff --git a/lib/assets/javascripts/views/plans/index.js b/lib/assets/javascripts/views/plans/index.js
index a504bbb..8ce3de7 100644
--- a/lib/assets/javascripts/views/plans/index.js
+++ b/lib/assets/javascripts/views/plans/index.js
@@ -1,4 +1,9 @@
-import { PLAN_VISIBILITY_WHEN_TEST, PLAN_VISIBILITY_WHEN_NOT_TEST, PLAN_VISIBILITY_WHEN_NOT_TEST_TOOLTIP } from '../../constants';
+import * as notifier from '../../utils/notificationHelper';
+import {
+ PLAN_VISIBILITY_WHEN_TEST,
+ PLAN_VISIBILITY_WHEN_NOT_TEST,
+ PLAN_VISIBILITY_WHEN_NOT_TEST_TOOLTIP,
+} from '../../constants';
$(() => {
const checkboxHandler = (el) => {
@@ -9,8 +14,11 @@
url: $(form).attr('action'),
data: $(form).serializeArray(),
}).done((data) => {
- $('#notification-area').removeClass('hide').find('span').last()
- .html(data.msg);
+ if (data.code === 1 && data.msg && data.msg !== '') {
+ notifier.renderNotice(data.msg);
+ } else {
+ notifier.renderAlert(data.msg);
+ }
if ($(el).is(':checked')) {
$(form).parent().siblings('.plan-visibility').html(PLAN_VISIBILITY_WHEN_TEST)
@@ -24,7 +32,7 @@
});
};
- $("input[type='checkbox']").on('click, change', (e) => {
+ $("#my-plans input[type='checkbox']").on('click, change', (e) => {
checkboxHandler(e.currentTarget);
});
});
diff --git a/lib/assets/javascripts/views/plans/new.js b/lib/assets/javascripts/views/plans/new.js
index e5ce707..63ed8c9 100644
--- a/lib/assets/javascripts/views/plans/new.js
+++ b/lib/assets/javascripts/views/plans/new.js
@@ -1,6 +1,8 @@
+import debounce from '../../utils/debounce';
import ariatiseForm from '../../utils/ariatiseForm';
import initAutoComplete from '../../utils/autoComplete';
import { isObject, isArray } from '../../utils/isType';
+import { isValidText } from '../../utils/isValidInputType';
$(() => {
// AJAX success function for available template search
@@ -38,29 +40,27 @@
const getMethod = jQueryForm => jQueryForm.attr('method');
// When one of the autocomplete fields changes, fetch the available templates
- const handleComboboxChange = () => {
- if ($('#plan_org_id').length && $('#plan_funder_id').length) {
- const validOrg = ($('#plan_org_id').val().trim().length > 0 || $('#plan_no_org').prop('checked'));
- const validFunder = ($('#plan_funder_id').val().trim().length > 0 || $('#plan_no_funder').prop('checked'));
+ const handleComboboxChange = debounce(() => {
+ const validOrg = (isValidText($('#plan_org_id').val()) || $('#plan_no_org').prop('checked'));
+ const validFunder = (isValidText($('#plan_funder_id').val()) || $('#plan_no_funder').prop('checked'));
- if (!validOrg || !validFunder) {
- $('#available-templates').fadeOut();
- $('#plan_template_id').val('');
- } else {
- // Clear out the old template dropdown contents
- $('#plan_template_id option').remove();
+ if (!validOrg || !validFunder) {
+ $('#available-templates').fadeOut();
+ $('#plan_template_id').val('');
+ } else {
+ // Clear out the old template dropdown contents
+ $('#plan_template_id option').remove();
- // Fetch the available templates fbased on the funder and research org selected
- const jQueryForm = $('form');
- const formElements = jQueryForm.serializeArray();
- $.ajax({
- method: getMethod(jQueryForm),
- url: getAction(jQueryForm),
- data: formElements,
- }).done(success, error);
- }
+ // Fetch the available templates fbased on the funder and research org selected
+ const jQueryForm = $('form#new_plan');
+ const formElements = jQueryForm.serializeArray();
+ $.ajax({
+ method: getMethod(jQueryForm),
+ url: getAction(jQueryForm),
+ data: formElements,
+ }).done(success, error);
}
- };
+ }, 150);
// When one of the checkboxes is clicked, disable the autocomplete input and clear its contents
const handleCheckboxClick = (name, checked) => {
@@ -107,6 +107,7 @@
});
// Initialize the form
+ $('#available-templates').hide();
handleComboboxChange();
if ($('#plan_no_org').prop('checked')) {
handleCheckboxClick('org', $('#plan_no_org').prop('checked'));
diff --git a/lib/assets/javascripts/views/plans/share.js b/lib/assets/javascripts/views/plans/share.js
index e85491e..0d1aece 100644
--- a/lib/assets/javascripts/views/plans/share.js
+++ b/lib/assets/javascripts/views/plans/share.js
@@ -1,6 +1,34 @@
+import * as notifier from '../../utils/notificationHelper';
import ariatiseForm from '../../utils/ariatiseForm';
$(() => {
// Invite Collaborators form on the Share page
ariatiseForm({ selector: '#new_role' });
+
+ const xhrRequest = (el) => {
+ const form = $(el).closest('form');
+
+ $.ajax({
+ method: $(form).attr('method'),
+ url: $(form).attr('action'),
+ data: $(form).serializeArray(),
+ dataType: 'json',
+ }).done((data) => {
+ if (data.code === 1 && data.msg && data.msg !== '') {
+ notifier.renderNotice(data.msg);
+ } else {
+ notifier.renderAlert(data.msg);
+ }
+ }, () => {
+ // TODO adequate error handling for network error
+ });
+ };
+
+ $('#set_visibility [name="plan[visibility]"]').click((e) => {
+ xhrRequest(e.currentTarget);
+ });
+
+ $('.change_plan_role select').change((e) => {
+ xhrRequest(e.currentTarget);
+ });
});
diff --git a/lib/assets/javascripts/views/shared/sign_in_form.js b/lib/assets/javascripts/views/shared/sign_in_form.js
index baac16e..f265b67 100644
--- a/lib/assets/javascripts/views/shared/sign_in_form.js
+++ b/lib/assets/javascripts/views/shared/sign_in_form.js
@@ -1,7 +1,32 @@
+import * as Cookies from 'js-cookie';
import ariatiseForm from '../../utils/ariatiseForm';
import { togglisePasswords } from '../../utils/passwordHelper';
$(() => {
ariatiseForm({ selector: '#sign_in_form' });
togglisePasswords({ selector: '#sign_in_form' });
+
+ const email = Cookies.get('dmproadmap_email');
+
+ // If the user's email was stored in the browser's cookies the pre-populate the field
+ if (email && email !== '') {
+ $('#sign_in_form #remember_email').attr('checked', 'checked');
+ $('#sign_in_form #user_email').val(email);
+ }
+
+ // When the user checks the 'remember email' box store the value in the browser storage
+ $('#sign_in_form #remember_email').click((e) => {
+ if ($(e.currentTarget).is(':checked')) {
+ Cookies.set('dmproadmap_email', $('#sign_in_form #user_email').val(), { expires: 14 });
+ } else {
+ Cookies.remove('dmproadmap_email');
+ }
+ });
+
+ // If the email is changed and the user has asked to remember it update the browser storage
+ $('#sign_in_form #user_email').change((e) => {
+ if ($('#sign_in_form #remember_email').is(':checked')) {
+ Cookies.set('dmproadmap_email', $(e.currentTarget).val(), { expires: 14 });
+ }
+ });
});
diff --git a/lib/assets/package-lock.json b/lib/assets/package-lock.json
index d43dad4..fdd4011 100644
--- a/lib/assets/package-lock.json
+++ b/lib/assets/package-lock.json
@@ -4676,6 +4676,11 @@
"integrity": "sha1-8OgK4DmkvWVLXygfyT8EqRSn/M4=",
"dev": true
},
+ "js-cookie": {
+ "version": "2.1.4",
+ "resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-2.1.4.tgz",
+ "integrity": "sha1-2k7FA4ZvFJ0WTPJfV57zEBUCXY0="
+ },
"js-tokens": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz",
diff --git a/lib/assets/package.json b/lib/assets/package.json
index 21e1786..47fcbdc 100644
--- a/lib/assets/package.json
+++ b/lib/assets/package.json
@@ -24,6 +24,7 @@
"jquery-accessible-autocomplete-list-aria": "1.5.5",
"jquery-ui-dist": "1.12.1",
"jquery-ujs": "1.2.2",
+ "js-cookie": "2.1.4",
"placeholder": "1.0.2",
"tablesorter": "2.28.15",
"timeago": "1.6.1",
diff --git a/lib/assets/webpack.config.js b/lib/assets/webpack.config.js
index 63fd3eb..f249c73 100644
--- a/lib/assets/webpack.config.js
+++ b/lib/assets/webpack.config.js
@@ -75,22 +75,6 @@
new CopyWebPackPlugin([ // Copies every file under images or videos
{ from: './images/**/*', to: `${destPath}/` },
{ from: './videos/**/*', to: `${destPath}/` },
- /* START DEPENDENCIES NEEDED FOR ES5 scripts */
- { from: './node_modules/jquery/dist/jquery.min.js', to: `${destPath}/javascripts/` },
- { from: './node_modules/jquery-ujs/src/rails.js', to: `${destPath}/javascripts/` },
- { from: './node_modules/jquery-ui-dist/jquery-ui.min.js', to: `${destPath}/javascripts/` },
- { from: './node_modules/jquery-accessible-autocomplete-list-aria/jquery-accessible-autocomplete-list-aria.js', to: `${destPath}/javascripts/` },
- { from: './node_modules/placeholder/dist/placeholder.min.js', to: `${destPath}/javascripts/` },
- { from: './node_modules/tablesorter/dist/js/jquery.tablesorter.min.js', to: `${destPath}/javascripts/` },
- { from: './node_modules/tablesorter/dist/js/jquery.tablesorter.widgets.min.js', to: `${destPath}/javascripts/` },
- { from: './node_modules/timeago/jquery.timeago.js', to: `${destPath}/javascripts/` },
- { from: './node_modules/tinymce/tinymce.min.js', to: `${destPath}/javascripts/` },
- { from: './node_modules/bootstrap-sass/assets/javascripts/bootstrap.min.js', to: `${destPath}/javascripts/` },
- { from: './javascripts/utils_es5/**/*', to: `${destPath}/` },
- { from: './javascripts/dmproadmap/**/*', to: `${destPath}/` },
- { from: './javascripts/views/**/*', to: `${destPath}/` },
- { from: './javascripts/admin.js', to: `${destPath}/javascripts/` },
- /* END DEPENDENCIES NEEDED FOR ES5 scripts */
]),
function deleteAssets() { // Deletes ONLY files within the following paths.
const relativePaths = ['/javascripts', '/stylesheets', '/fonts'];
diff --git a/lib/tasks/logos.rake b/lib/tasks/logos.rake
new file mode 100644
index 0000000..9878ecd
--- /dev/null
+++ b/lib/tasks/logos.rake
@@ -0,0 +1,12 @@
+namespace :logos do
+ desc "Resize all of the logos based on the settings in `models/org.rb`"
+ task resize_all: :environment do
+ Org.all.each do |org|
+ if org.logo.present?
+ img = org.logo
+ org.logo = img
+ org.save!
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/test/functional/plans_controller_test.rb b/test/functional/plans_controller_test.rb
index ef6a4f4..c61c47c 100644
--- a/test/functional/plans_controller_test.rb
+++ b/test/functional/plans_controller_test.rb
@@ -148,23 +148,22 @@
# ----------------------------------------------------------
test 'duplicate a plan' do
# Should redirect user to the root path if they are not logged in!
- post duplicate_plan_path(@plan, format: :js)
+ post duplicate_plan_path(@plan)
assert_unauthorized_redirect_to_root_path
# User who is does not have access to the plan
sign_in User.first
- put plan_path(@plan, format: :js)
+ put plan_path(@plan)
assert_equal _('You are not authorized to perform this action.'), flash[:alert]
assert_response :redirect
assert_redirected_to plans_url
sign_in @user
- post duplicate_plan_path(@plan, format: :js)
+ post duplicate_plan_path(@plan)
@duplicate_plan = Plan.last
assert flash[:notice].start_with?('Successfully') && flash[:notice].include?('copied')
- assert_response :success
- assert assigns(:plan)
- assert_equal 'Copy of Test Plan', @duplicate_plan.title, "Copy of"
+ assert_response :redirect
+ assert_redirected_to plan_url(@duplicate_plan)
end
diff --git a/test/unit/org_test.rb b/test/unit/org_test.rb
index a4b2617..dd0bf5a 100644
--- a/test/unit/org_test.rb
+++ b/test/unit/org_test.rb
@@ -76,7 +76,7 @@
end
# ---------------------------------------------------
- test "should resize logo to a height of 165" do
+ test "should resize logo to a height of 75" do
['logo.jpg', # this one is at 160x160
'logo_300x300.jpg',
'logo_100x100.jpg'].each do |file|
@@ -85,7 +85,7 @@
@org.logo = Dragonfly.app.fetch_file("#{path}")
assert @org.valid?, "expected the logo to have been attached to the org"
- assert_equal 165, @org.logo.height, "expected the logo to have been resized properly"
+ assert_equal 75, @org.logo.height, "expected the logo to have been resized properly"
end
end