Skip to content

Commit

Permalink
Export release-8963@594d6837
Browse files Browse the repository at this point in the history
  • Loading branch information
Hasso Plattner Institut committed Jan 13, 2025
1 parent d8509b1 commit 706cd9b
Show file tree
Hide file tree
Showing 20 changed files with 307 additions and 277 deletions.
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22.12.0
22.13.0
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ gem 'sprockets', '~> 3.2'
gem 'sprockets-rails', '~> 3.2'

group :assets do
gem 'bootstrap-x-editable-rails'
gem 'dartsass-sprockets'
gem 'highcharts-rails'
gem 'i18n-js', '~> 3.0', '>= 3.0.1'
Expand Down
21 changes: 9 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ GEM
awesome_nested_set (3.8.0)
activerecord (>= 4.0.0, < 8.1)
aws-eventstream (1.3.0)
aws-partitions (1.1031.0)
aws-sdk-core (3.214.1)
aws-partitions (1.1035.0)
aws-sdk-core (3.215.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.9)
Expand All @@ -202,7 +202,7 @@ GEM
aws-sdk-core (~> 3, >= 3.210.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.10.1)
aws-sigv4 (1.11.0)
aws-eventstream (~> 1, >= 1.0.2)
base62-rb (0.3.1)
base64 (0.2.0)
Expand All @@ -218,8 +218,6 @@ GEM
debug_inspector (>= 1.2.0)
bootsnap (1.18.4)
msgpack (~> 1.2)
bootstrap-x-editable-rails (1.5.1.1)
railties (>= 3.0)
brakeman (6.2.2)
racc
browser (6.2.0)
Expand All @@ -243,7 +241,7 @@ GEM
coderay (1.1.3)
colorize (1.1.0)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
connection_pool (2.5.0)
countries (7.1.0)
unaccent (~> 0.3)
crack (1.0.0)
Expand Down Expand Up @@ -335,10 +333,10 @@ GEM
i18n (>= 0.7)
multi_json
request_store (>= 1.0)
google-protobuf (4.29.2)
google-protobuf (4.29.3)
bigdecimal
rake (>= 13)
google-protobuf (4.29.2-x86_64-linux)
google-protobuf (4.29.3-x86_64-linux)
bigdecimal
rake (>= 13)
grape (1.8.0)
Expand Down Expand Up @@ -430,7 +428,7 @@ GEM
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
little-plugger (1.1.4)
logger (1.6.4)
logger (1.6.5)
logging (2.4.0)
little-plugger (~> 1.1)
multi_json (~> 1.14)
Expand Down Expand Up @@ -469,7 +467,7 @@ GEM
mime-types (3.6.0)
logger
mime-types-data (~> 3.2015)
mime-types-data (3.2024.1203)
mime-types-data (3.2025.0107)
mini_mime (1.1.5)
mini_portile2 (2.8.8)
minitest (5.25.4)
Expand Down Expand Up @@ -697,7 +695,7 @@ GEM
redcarpet (3.6.0)
redis (5.3.0)
redis-client (>= 0.22.0)
redis-client (0.23.0)
redis-client (0.23.1)
connection_pool
regexp_parser (2.10.0)
reline (0.6.0)
Expand Down Expand Up @@ -950,7 +948,6 @@ DEPENDENCIES
bigdecimal
binding_of_caller
bootsnap
bootstrap-x-editable-rails
brakeman
browser (~> 6.0)
capybara (~> 3.36)
Expand Down
220 changes: 220 additions & 0 deletions app/assets/legacy/account-profile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
/* eslint-disable no-undef */

// We cannot import $ because the bootstrap-editable plugin
// expects it to be globally available.
import 'jquery';
import './bootstrap-editable';

import { showLoading, hideLoading } from '../util/loading';

const service_unavailable = I18n.t('dashboard.profile.service_unavailable');
const error_message = I18n.t('dashboard.profile.error_message');
const email_already_taken = I18n.t('dashboard.profile.email_already_taken');

// Settings for birthdate inline editor
const combodate_format = I18n.t('dashboard.profile.combodate_format');
const combodate_viewformat = I18n.t('dashboard.profile.combodate_viewformat');
const combodate_template = I18n.t('dashboard.profile.combodate_template');
const combodate_emptytext = I18n.t('dashboard.profile.not_set');

const isIE = function () {
return navigator.userAgent.toLowerCase().indexOf('msie') !== -1;
};

$(function () {
const ajaxurl = document.querySelector('[data-ajaxurl]').dataset.ajaxurl;

//Hint: x-editable can not deal with async requests within a success function...
function doAjaxRequest($element, data, success, error) {
var result = null;
try {
$.ajax(ajaxurl, {
type: 'POST',
async: false,
data: data,
success: function (msg, newValue) {
result = success(msg, newValue);
if (!$element.hasClass('editable-updated'))
$element.addClass('editable-updated');
},
error: function (response) {
$element.removeClass('editable-updated');
if (typeof error === 'function') result = error(response);
if (result) return;
if (response.status === 500) result = service_unavailable;
else result = error_message;
},
});
} catch (response) {
if (typeof error === 'function') error(response);
result = service_unavailable;
}
return result;
}

$('#form-changepassword').hide();

$('.editable')
.not('.editable-required')
.editable({
success: function () {
if (!$(this).hasClass('editable-updated'))
$(this).addClass('editable-updated');
},
error: function (response) {
$(this).removeClass('editable-updated');
if (response.status === 500) return service_unavailable;
return error_message;
},
});

$('.editable-required').editable({
onblur: 'submit',
success: function () {
if (!$(this).hasClass('editable-updated'))
$(this).addClass('editable-updated');
},
error: function (response) {
$(this).removeClass('editable-updated');
if (response.status === 500) return service_unavailable;
return error_message;
},
});

$('#display_name').editable({
success: function (msg, newValue) {
$('#nav-username').closest('.has-spinner').addClass('loading');
$('#username_preview').prev('.has-spinner').addClass('loading');
return doAjaxRequest(
$('#display_name'),
{
display_name: newValue,
},
function (msg) {
$('#nav-username').closest('.has-spinner').removeClass('loading');
$('#username_preview').prev('.has-spinner').removeClass('loading');
$('#nav-username').html(msg.user.name);
$('#username_preview').html(msg.user.name);
if (msg.user.display_name.length > 0) {
return $('#display_name').html(msg.user.display_name);
} else {
return location.reload();
}
},
function () {
$('#nav-username').closest('.has-spinner').removeClass('loading');
$('#username_preview').prev('.has-spinner').removeClass('loading');
},
);
},
});

$('#full_name').editable({
success: function (msg, newValue) {
$('#nav-username').closest('.has-spinner').addClass('loading');
$('#username_preview').prev('.has-spinner').addClass('loading');
return doAjaxRequest(
$('#full_name'),
{
full_name: newValue,
},
function (msg) {
$('#nav-username').closest('.has-spinner').removeClass('loading');
$('#username_preview').prev('.has-spinner').removeClass('loading');
$('#nav-username').html(msg.user.name);
return $('#username_preview').html(msg.user.name);
},
function () {
$('#nav-username').closest('.has-spinner').removeClass('loading');
$('#username_preview').prev('.has-spinner').removeClass('loading');
},
);
},
});

$('#changepassword-button').on('click', function (evt) {
evt.preventDefault();
$('#form-changepassword').show();
$('#changepassword').hide();
});

$('#changepassword-cancel').on('click', function (evt) {
evt.preventDefault();
$('#form-changepassword').hide();
$('#changepassword').show();
});

$('#user_visual').on('click', function (evt) {
evt.preventDefault();
if (!isIE()) {
return $('#user_visual_upload').click();
} else {
$('#user_visual_upload').toggleClass('hide');
return $('#user_visual_submit').toggleClass('hide');
}
});

$('#user_visual_upload').change(function () {
if (!isIE()) {
this.form.submit();
}
});

$('#email').editable({
success: function (msg, newValue) {
showLoading();
return doAjaxRequest(
$('#email'),
{
email: newValue,
},
function (msg) {
$('#email').html(msg.email);
return document.location.reload();
},
function (response) {
hideLoading();
if (
response.responseText.split(', ').includes('has already been taken')
)
return email_already_taken;
},
);
},
});

$('#born_at').editable({
format: combodate_format,
emptytext: combodate_emptytext,
viewformat: combodate_viewformat,
template: combodate_template,
combodate: {
language: $('html').attr('lang'),
minYear: 1910,
maxYear: new Date().getFullYear(),
},
success: function (msg, newValue) {
if (newValue) {
newValue = newValue.add('m', -newValue.zone()).toISOString();
}
return doAjaxRequest(
$('#born_at'),
{
born_at: newValue,
},
function (msg) {
return $('#born_at').data('value', msg);
},
);
},
});

$('#secondary-emails-list').hide();
$('#secondary-emails-hide-button').hide();
return $('.secondary-emails-button').on('click', function (evt) {
evt.preventDefault();
$('#secondary-emails-list').toggle();
$('#secondary-emails-show-button').toggle();
$('#secondary-emails-hide-button').toggle();
});
});
10 changes: 7 additions & 3 deletions app/assets/legacy/bootstrap-editable.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/* eslint-disable no-undef */
// We cannot import the $ because the bootstrap-editable plugin
// expects it to be globally available.
import 'jquery';

// The bootstrap editable type 'combodate' needs moment.js
// with locales to format and display the input fields.
import moment from 'moment/min/moment-with-locales';
window.moment = moment;
moment.locale(document.documentElement.lang);

import '../../../vendor/assets/javascripts/bootstrap-editable';

$.fn.editableform.buttons =
Expand Down
Loading

0 comments on commit 706cd9b

Please sign in to comment.