Skip to content

Commit

Permalink
Lint JS
Browse files Browse the repository at this point in the history
  • Loading branch information
fdaugan committed Aug 29, 2023
1 parent 7ecfb61 commit 5f10bb1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ define(function () {
const $source = $(event.relatedTarget);
const $tr = $source.closest('tr');
let uc = ($tr.length && current.table.fnGetData($tr[0])) || undefined;
uc = uc && uc.id ? uc : {};
uc = uc?.id ? uc : {};
current.currentId = uc.id;
_('modal-title').html(Handlebars.compile(current.$messages['container-scope-title'])(current.$messages[current.containerType]));
_('name').val(uc.name || null);
Expand All @@ -63,7 +63,7 @@ define(function () {

// Global datatables filter
_('search').on('keyup', function () {
current.table && current.table.fnFilter($(this).val());
current.table?.fnFilter($(this).val());
});

// Also initialize the datatables component
Expand Down Expand Up @@ -125,7 +125,7 @@ define(function () {
success: function (data) {
notifyManager.notify(Handlebars.compile(
current.$messages[current.currentId ? 'updated' : 'created'])(current.currentId || data));
current.table && current.table.api().ajax.reload();
current.table?.api().ajax.reload();
_('popup').modal('hide');
}
});
Expand All @@ -142,7 +142,7 @@ define(function () {
url: REST_PATH + 'service/id/container-scope/' + id,
success: function () {
notifyManager.notify(Handlebars.compile(current.$messages.deleted)(text + '(' + id + ')'));
current.table && current.table.api().ajax.reload();
current.table?.api().ajax.reload();
}
});
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ define(function () {
success: function (id) {
$('.import-summary').html('Processing...');
current.$parent.scheduleUploadStep('service/id/group/batch', id, function() {
current.table && current.table.api().ajax.reload();
current.table?.api().ajax.reload();
});
}
});
Expand Down Expand Up @@ -218,7 +218,7 @@ define(function () {
data: JSON.stringify(data),
success: function () {
notifyManager.notify(Handlebars.compile(current.$messages.created)(data.name));
current.table && current.table.api().ajax.reload();
current.table?.api().ajax.reload();
_('popup').modal('hide');
}
});
Expand All @@ -235,7 +235,7 @@ define(function () {
url: REST_PATH + 'service/id/' + current.containerType + '/' + id,
success: function () {
notifyManager.notify(Handlebars.compile(current.$messages.deleted)(id));
current.table && current.table.api().ajax.reload();
current.table?.api().ajax.reload();
}
});
} else {
Expand All @@ -258,7 +258,7 @@ define(function () {
url: REST_PATH + 'service/id/' + current.containerType + '/empty/' + id,
success: function () {
notifyManager.notify(Handlebars.compile(current.$messages.updated)(id));
current.table && current.table.api().ajax.reload();
current.table?.api().ajax.reload();
}
});
} else {
Expand Down
14 changes: 7 additions & 7 deletions src/main/resources/META-INF/resources/webjars/id/home/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
define(function () {
function validateMail() {
const mail = _('mail').val();
if (mail.match(/^.*@(gmail|yahoo|free|sfr|live|hotmail)\.[a-zA-Z]+$/i)) {
if (mail.match(/^.*@(gmail|yahoo|free|sfr|live|hotmail)\.[a-z]+$/i)) {
validationManager.addWarn(_('mail'), 'warn-mail-perso');
} else {
validationManager.reset(_('mail'));
Expand Down Expand Up @@ -174,7 +174,7 @@ define(function () {
});
// Global datatables filter
_('search').on('keyup', function () {
current.table && current.table.fnFilter($(this).val());
current.table?.fnFilter($(this).val());
});

_('table')
Expand Down Expand Up @@ -352,7 +352,7 @@ define(function () {
} else {
notifyManager.notify(Handlebars.compile(current.$messages['created-account'])(data));
}
current.table && current.table.api().ajax.reload();
current.table?.api().ajax.reload();
if ($('#create-another:checked').length) {
// Only reset the popup
current.fillPopup({});
Expand Down Expand Up @@ -380,7 +380,7 @@ define(function () {
_('lastName').val(uc.lastName || '');
_('department').val(uc.department || '');
_('localId').val(uc.localId || '');
_('mail').val((uc.mails && uc.mails[0]) || '');
_('mail').val((uc.mails?.[0]) || '');
_('company').select2('val', uc.company || null);
_('groups').select2('data', (uc.groups || []).map(g => ({
id: g.name,
Expand Down Expand Up @@ -418,7 +418,7 @@ define(function () {
url: REST_PATH + 'service/id/user/' + id,
success: function () {
notifyManager.notify(Handlebars.compile(current.$messages.deleted)(name));
current.table && current.table.api().ajax.reload();
current.table?.api().ajax.reload();
}
});
} else {
Expand Down Expand Up @@ -475,7 +475,7 @@ define(function () {
url: REST_PATH + 'service/id/user/' + id + '/' + operation,
success: function (data) {
notifyManager.notify(Handlebars.compile(current.$messages[operated + '-confirm'])(name));
current.table && current.table.api().ajax.reload();
current.table?.api().ajax.reload();
if (operation === 'reset') {
// Callback the popup to display the generated password
_('generated-password').val(data);
Expand Down Expand Up @@ -504,7 +504,7 @@ define(function () {
url: REST_PATH + 'service/id/user/' + id + '/' + operation,
success: function () {
notifyManager.notify(Handlebars.compile(current.$messages[operated + '-confirm'])(name));
current.table && current.table.api().ajax.reload();
current.table?.api().ajax.reload();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ define(function () {
}
}).on('change', function (e) {
// Member might be selected, enable the 'add' button
if (e.added && e.added.id) {
if (e.added?.id) {
// Enable the button
_('add-user').removeAttr('disabled');
} else {
Expand All @@ -127,14 +127,14 @@ define(function () {
type: 'PUT',
success: function () {
notifyManager.notify(Handlebars.compile(current.$messages['service:id:added-member'])([user, group]));
current.table && current.table.api().ajax.reload();
current.table?.api().ajax.reload();
}
});
});

// Global datatables filter
_('subscribe-configuration-id-search').on('keyup', function () {
current.table && current.table.fnFilter($(this).val());
current.table?.fnFilter($(this).val());
});

// Remove the selected user from the current group
Expand All @@ -147,7 +147,7 @@ define(function () {
type: 'DELETE',
success: function () {
notifyManager.notify(Handlebars.compile(current.$messages['service:id:removed-member'])([user, group]));
current.table && current.table.api().ajax.reload();
current.table?.api().ajax.reload();
}
});
});
Expand Down

0 comments on commit 5f10bb1

Please sign in to comment.