Changeset View
Changeset View
Standalone View
Standalone View
assets/src/bundles/save/index.js
Show All 27 Lines | csrfPost(addSaveOriginRequestUrl) | ||||
.catch(response => { | .catch(response => { | ||||
$('.swh-processing-save-request').css('display', 'none'); | $('.swh-processing-save-request').css('display', 'none'); | ||||
response.json().then(errorData => { | response.json().then(errorData => { | ||||
errorCallback(response.status, errorData); | errorCallback(response.status, errorData); | ||||
}); | }); | ||||
}); | }); | ||||
} | } | ||||
const userRequestsFilterCheckbox = ` | |||||
<div class="custom-control custom-checkbox swhid-option"> | |||||
<input class="custom-control-input" value="option-user-requests-filter" type="checkbox" | |||||
id="swh-save-requests-user-filter"> | |||||
<label class="custom-control-label font-weight-normal" for="swh-save-requests-user-filter"> | |||||
show only your requests | |||||
vlorentz: might be a bit clearer like this | |||||
</label> | |||||
</div> | |||||
`; | |||||
export function initOriginSave() { | export function initOriginSave() { | ||||
$(document).ready(() => { | $(document).ready(() => { | ||||
$.fn.dataTable.ext.errMode = 'none'; | $.fn.dataTable.ext.errMode = 'none'; | ||||
fetch(Urls.origin_save_types_list()) | fetch(Urls.origin_save_types_list()) | ||||
.then(response => response.json()) | .then(response => response.json()) | ||||
Show All 9 Lines | saveRequestsTable = $('#swh-origin-save-requests') | ||||
console.log(message); | console.log(message); | ||||
}) | }) | ||||
.DataTable({ | .DataTable({ | ||||
serverSide: true, | serverSide: true, | ||||
processing: true, | processing: true, | ||||
language: { | language: { | ||||
processing: `<img src="${swhSpinnerSrc}"></img>` | processing: `<img src="${swhSpinnerSrc}"></img>` | ||||
}, | }, | ||||
ajax: Urls.origin_save_requests_list('all'), | ajax: { | ||||
url: Urls.origin_save_requests_list('all'), | |||||
data: (d) => { | |||||
if (swh.webapp.isUserLoggedIn() && $('#swh-save-requests-user-filter').prop('checked')) { | |||||
d.user_requests_only = '1'; | |||||
} | |||||
} | |||||
}, | |||||
searchDelay: 1000, | searchDelay: 1000, | ||||
dom: '<"row"<"col-sm-3"l><"col-sm-6 text-left user-requests-filter"><"col-sm-3"f>>' + | |||||
'<"row"<"col-sm-12"tr>>' + | |||||
'<"row"<"col-sm-5"i><"col-sm-7"p>>', | |||||
anlambertAuthorUnsubmitted Done Inline Actionsthat weird syntax set the datatables UI components plus an extra one while not breaking the bootstrap layout. anlambert: that weird syntax set the datatables UI components plus an extra one while not breaking the… | |||||
ardumontUnsubmitted Not Done Inline Actionsyes, thanks, I recall datatable are highly configurable and some with weird syntax ;) Maybe inline your comment in the code directly so we can refer to it next time we encouter and scratch our heads ;) ardumont: yes, thanks, I recall datatable are highly configurable and some with weird syntax ;)
Maybe… | |||||
vlorentzUnsubmitted Not Done Inline ActionsI was about to ask about this. I still don't understand what is happening here after reading that page. Could you explain it with a comment in the code? vlorentz: I was about to ask about this.
I still don't understand what is happening here after reading… | |||||
anlambertAuthorUnsubmitted Done Inline Actionssure anlambert: sure | |||||
fnInitComplete: function() { | |||||
if (swh.webapp.isUserLoggedIn()) { | |||||
$('div.user-requests-filter').html(userRequestsFilterCheckbox); | |||||
$('#swh-save-requests-user-filter').on('change', () => { | |||||
saveRequestsTable.draw(); | |||||
}); | |||||
} | |||||
}, | |||||
columns: [ | columns: [ | ||||
{ | { | ||||
data: 'save_request_date', | data: 'save_request_date', | ||||
name: 'request_date', | name: 'request_date', | ||||
render: (data, type, row) => { | render: (data, type, row) => { | ||||
if (type === 'display') { | if (type === 'display') { | ||||
let date = new Date(data); | let date = new Date(data); | ||||
return date.toLocaleString(); | return date.toLocaleString(); | ||||
▲ Show 20 Lines • Show All 380 Lines • Show Last 20 Lines |
might be a bit clearer like this