mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-30 08:31:34 +00:00
.devcontainer
.github
.vscode
InvenTree
InvenTree
build
common
company
label
locale
order
part
plugin
plugins
report
script
stock
templates
InvenTree
account
allauth_2fa
email
js
dynamic
calendar.js
nav.js
settings.js
translated
patterns
plugin
registration
sample
socialaccount
403.html
403_csrf.html
404.html
500.html
503.html
about.html
admin_button.html
attachment_button.html
attachment_table.html
base.html
clip.html
collapse_rows.html
expand_rows.html
filter_list.html
hover_image.html
mail.html
modal_csrf.html
modal_delete_form.html
modal_form.html
modals.html
navbar.html
notes_buttons.html
notifications.html
page_base.html
panel.html
price.html
qr_button.html
qr_code.html
search.html
search_form.html
sidebar_header.html
sidebar_item.html
sidebar_link.html
sidebar_toggle.html
skeleton.html
spacer.html
stats.html
status_codes.html
stock_table.html
tel.html
third_party_js.html
url.html
version.html
yesnolabel.html
users
config_template.yaml
gunicorn.conf.py
manage.py
ci
deploy
docker
images
.eslintrc.yml
.gitattributes
.gitignore
.gitpod.yml
.pre-commit-config.yaml
CONTRIBUTING.md
Dockerfile
LICENSE
README.md
RELEASE.md
SECURITY.md
crowdin.yml
docker-compose.yml
docker.dev.env
package-lock.json
package.json
requirements-dev.in
requirements-dev.txt
requirements.in
requirements.txt
setup.cfg
tasks.py
66 lines
1.3 KiB
JavaScript
66 lines
1.3 KiB
JavaScript
{% load i18n %}
|
|
|
|
/* globals
|
|
*/
|
|
|
|
/* exported
|
|
clearEvents,
|
|
endDate,
|
|
startDate,
|
|
renderDate,
|
|
*/
|
|
|
|
/**
|
|
* Helper functions for calendar display
|
|
*/
|
|
|
|
function startDate(calendar) {
|
|
// Extract the first displayed date on the calendar
|
|
return calendar.currentData.dateProfile.activeRange.start.toISOString().split('T')[0];
|
|
}
|
|
|
|
function endDate(calendar) {
|
|
// Extract the last display date on the calendar
|
|
return calendar.currentData.dateProfile.activeRange.end.toISOString().split('T')[0];
|
|
}
|
|
|
|
function clearEvents(calendar) {
|
|
// Remove all events from the calendar
|
|
|
|
var events = calendar.getEvents();
|
|
|
|
events.forEach(function(event) {
|
|
event.remove();
|
|
});
|
|
}
|
|
|
|
|
|
/*
|
|
* Render the provided date in the user-specified format.
|
|
*
|
|
* The provided "date" variable is a string, nominally ISO format e.g. 2022-02-22
|
|
* The user-configured setting DATE_DISPLAY_FORMAT determines how the date should be displayed.
|
|
*/
|
|
|
|
function renderDate(date, options={}) {
|
|
|
|
if (!date) {
|
|
return null;
|
|
}
|
|
|
|
var fmt = user_settings.DATE_DISPLAY_FORMAT || 'YYYY-MM-DD';
|
|
|
|
if (options.showTime) {
|
|
fmt += ' HH:mm';
|
|
}
|
|
|
|
var m = moment(date);
|
|
|
|
if (m.isValid()) {
|
|
return m.format(fmt);
|
|
} else {
|
|
// Invalid input string, simply return provided value
|
|
return date;
|
|
}
|
|
}
|