lint: lint all js and sjon files with prettier

This commit is contained in:
billybonks 2024-02-06 16:26:41 +08:00 committed by Christopher Charbonneau Wells
parent e141492db7
commit f28df6ecf3
10 changed files with 662 additions and 692 deletions

View File

@ -1,16 +1,10 @@
{ {
"extends": "stylelint-config-recommended-scss", "extends": "stylelint-config-recommended-scss",
"plugins": [ "plugins": ["stylelint-order", "stylelint-scss"],
"stylelint-order",
"stylelint-scss"
],
"rules": { "rules": {
"at-rule-no-vendor-prefix": true, "at-rule-no-vendor-prefix": true,
"media-feature-name-no-vendor-prefix": true, "media-feature-name-no-vendor-prefix": true,
"order/order": [ "order/order": ["declarations", "rules"],
"declarations",
"rules"
],
"property-no-vendor-prefix": true, "property-no-vendor-prefix": true,
"selector-no-vendor-prefix": true, "selector-no-vendor-prefix": true,
"value-no-vendor-prefix": true "value-no-vendor-prefix": true

View File

@ -12,8 +12,7 @@
{ {
"model": "core.child", "model": "core.child",
"pk": 1, "pk": 1,
"fields": "fields": {
{
"first_name": "Fake", "first_name": "Fake",
"last_name": "Child", "last_name": "Child",
"birth_date": "2017-11-11", "birth_date": "2017-11-11",
@ -24,8 +23,7 @@
{ {
"model": "core.pumping", "model": "core.pumping",
"pk": 1, "pk": 1,
"fields": "fields": {
{
"child": 1, "child": 1,
"amount": 5.0, "amount": 5.0,
"start": "2017-11-17T17:52:00Z", "start": "2017-11-17T17:52:00Z",
@ -37,8 +35,7 @@
{ {
"model": "core.pumping", "model": "core.pumping",
"pk": 2, "pk": 2,
"fields": "fields": {
{
"child": 1, "child": 1,
"amount": 9.0, "amount": 9.0,
"start": "2017-11-17T20:03:00Z", "start": "2017-11-17T20:03:00Z",
@ -50,8 +47,7 @@
{ {
"model": "core.diaperchange", "model": "core.diaperchange",
"pk": 2, "pk": 2,
"fields": "fields": {
{
"child": 1, "child": 1,
"time": "2017-11-18T16:00:00Z", "time": "2017-11-18T16:00:00Z",
"wet": false, "wet": false,
@ -63,8 +59,7 @@
{ {
"model": "core.diaperchange", "model": "core.diaperchange",
"pk": 3, "pk": 3,
"fields": "fields": {
{
"child": 1, "child": 1,
"time": "2017-11-18T19:00:00Z", "time": "2017-11-18T19:00:00Z",
"wet": true, "wet": true,
@ -77,8 +72,7 @@
{ {
"model": "core.diaperchange", "model": "core.diaperchange",
"pk": 4, "pk": 4,
"fields": "fields": {
{
"child": 1, "child": 1,
"time": "2017-11-17T13:00:00Z", "time": "2017-11-17T13:00:00Z",
"wet": false, "wet": false,
@ -90,8 +84,7 @@
{ {
"model": "core.diaperchange", "model": "core.diaperchange",
"pk": 5, "pk": 5,
"fields": "fields": {
{
"child": 1, "child": 1,
"time": "2017-11-17T16:00:00Z", "time": "2017-11-17T16:00:00Z",
"wet": false, "wet": false,
@ -103,8 +96,7 @@
{ {
"model": "core.diaperchange", "model": "core.diaperchange",
"pk": 6, "pk": 6,
"fields": "fields": {
{
"child": 1, "child": 1,
"time": "2017-11-16T15:00:00Z", "time": "2017-11-16T15:00:00Z",
"wet": true, "wet": true,
@ -116,8 +108,7 @@
{ {
"model": "core.diaperchange", "model": "core.diaperchange",
"pk": 7, "pk": 7,
"fields": "fields": {
{
"child": 1, "child": 1,
"time": "2017-11-16T18:00:00Z", "time": "2017-11-16T18:00:00Z",
"wet": true, "wet": true,
@ -129,8 +120,7 @@
{ {
"model": "core.diaperchange", "model": "core.diaperchange",
"pk": 8, "pk": 8,
"fields": "fields": {
{
"child": 1, "child": 1,
"time": "2017-11-15T15:00:00Z", "time": "2017-11-15T15:00:00Z",
"wet": false, "wet": false,
@ -142,8 +132,7 @@
{ {
"model": "core.diaperchange", "model": "core.diaperchange",
"pk": 9, "pk": 9,
"fields": "fields": {
{
"child": 1, "child": 1,
"time": "2017-11-15T13:00:00Z", "time": "2017-11-15T13:00:00Z",
"wet": true, "wet": true,
@ -155,8 +144,7 @@
{ {
"model": "core.diaperchange", "model": "core.diaperchange",
"pk": 10, "pk": 10,
"fields": "fields": {
{
"child": 1, "child": 1,
"time": "2017-11-15T16:00:00Z", "time": "2017-11-15T16:00:00Z",
"wet": true, "wet": true,
@ -168,8 +156,7 @@
{ {
"model": "core.diaperchange", "model": "core.diaperchange",
"pk": 11, "pk": 11,
"fields": "fields": {
{
"child": 1, "child": 1,
"time": "2017-11-15T21:00:00Z", "time": "2017-11-15T21:00:00Z",
"wet": true, "wet": true,
@ -181,8 +168,7 @@
{ {
"model": "core.diaperchange", "model": "core.diaperchange",
"pk": 12, "pk": 12,
"fields": "fields": {
{
"child": 1, "child": 1,
"time": "2017-11-14T15:00:00Z", "time": "2017-11-14T15:00:00Z",
"wet": true, "wet": true,
@ -194,8 +180,7 @@
{ {
"model": "core.diaperchange", "model": "core.diaperchange",
"pk": 13, "pk": 13,
"fields": "fields": {
{
"child": 1, "child": 1,
"time": "2017-11-13T14:00:00Z", "time": "2017-11-13T14:00:00Z",
"wet": true, "wet": true,
@ -207,8 +192,7 @@
{ {
"model": "core.diaperchange", "model": "core.diaperchange",
"pk": 14, "pk": 14,
"fields": "fields": {
{
"child": 1, "child": 1,
"time": "2017-11-13T18:00:00Z", "time": "2017-11-13T18:00:00Z",
"wet": true, "wet": true,
@ -220,8 +204,7 @@
{ {
"model": "core.diaperchange", "model": "core.diaperchange",
"pk": 15, "pk": 15,
"fields": "fields": {
{
"child": 1, "child": 1,
"time": "2017-11-12T15:00:00Z", "time": "2017-11-12T15:00:00Z",
"wet": true, "wet": true,
@ -233,8 +216,7 @@
{ {
"model": "core.diaperchange", "model": "core.diaperchange",
"pk": 16, "pk": 16,
"fields": "fields": {
{
"child": 1, "child": 1,
"time": "2017-11-11T15:00:00Z", "time": "2017-11-11T15:00:00Z",
"wet": true, "wet": true,
@ -246,8 +228,7 @@
{ {
"model": "core.feeding", "model": "core.feeding",
"pk": 1, "pk": 1,
"fields": "fields": {
{
"child": 1, "child": 1,
"start": "2017-11-18T09:00:00Z", "start": "2017-11-18T09:00:00Z",
"end": "2017-11-18T09:30:00Z", "end": "2017-11-18T09:30:00Z",
@ -260,8 +241,7 @@
{ {
"model": "core.feeding", "model": "core.feeding",
"pk": 2, "pk": 2,
"fields": "fields": {
{
"child": 1, "child": 1,
"start": "2017-11-18T11:30:00Z", "start": "2017-11-18T11:30:00Z",
"end": "2017-11-18T12:00:00Z", "end": "2017-11-18T12:00:00Z",
@ -274,8 +254,7 @@
{ {
"model": "core.feeding", "model": "core.feeding",
"pk": 3, "pk": 3,
"fields": "fields": {
{
"child": 1, "child": 1,
"start": "2017-11-18T14:00:00Z", "start": "2017-11-18T14:00:00Z",
"end": "2017-11-18T14:15:00Z", "end": "2017-11-18T14:15:00Z",
@ -289,8 +268,7 @@
{ {
"model": "core.feeding", "model": "core.feeding",
"pk": 4, "pk": 4,
"fields": "fields": {
{
"child": 1, "child": 1,
"start": "2017-11-17T14:00:00Z", "start": "2017-11-17T14:00:00Z",
"end": "2017-11-17T14:15:00Z", "end": "2017-11-17T14:15:00Z",
@ -304,8 +282,7 @@
{ {
"model": "core.feeding", "model": "core.feeding",
"pk": 5, "pk": 5,
"fields": "fields": {
{
"child": 1, "child": 1,
"start": "2017-11-11T14:00:00Z", "start": "2017-11-11T14:00:00Z",
"end": "2017-11-11T14:15:00Z", "end": "2017-11-11T14:15:00Z",
@ -319,8 +296,7 @@
{ {
"model": "core.feeding", "model": "core.feeding",
"pk": 6, "pk": 6,
"fields": "fields": {
{
"child": 1, "child": 1,
"start": "2017-11-11T05:00:00Z", "start": "2017-11-11T05:00:00Z",
"end": "2017-11-11T05:15:00Z", "end": "2017-11-11T05:15:00Z",
@ -334,8 +310,7 @@
{ {
"model": "core.note", "model": "core.note",
"pk": 1, "pk": 1,
"fields": "fields": {
{
"child": 1, "child": 1,
"note": "Fake note.", "note": "Fake note.",
"time": "2017-11-18T03:45:00Z" "time": "2017-11-18T03:45:00Z"
@ -344,8 +319,7 @@
{ {
"model": "core.sleep", "model": "core.sleep",
"pk": 1, "pk": 1,
"fields": "fields": {
{
"child": 1, "child": 1,
"start": "2017-11-17T20:30:00Z", "start": "2017-11-17T20:30:00Z",
"end": "2017-11-18T05:30:00Z", "end": "2017-11-18T05:30:00Z",
@ -356,8 +330,7 @@
{ {
"model": "core.sleep", "model": "core.sleep",
"pk": 2, "pk": 2,
"fields": "fields": {
{
"child": 1, "child": 1,
"start": "2017-11-18T15:00:00Z", "start": "2017-11-18T15:00:00Z",
"end": "2017-11-18T17:00:00Z", "end": "2017-11-18T17:00:00Z",
@ -368,8 +341,7 @@
{ {
"model": "core.sleep", "model": "core.sleep",
"pk": 3, "pk": 3,
"fields": "fields": {
{
"child": 1, "child": 1,
"start": "2017-11-18T19:00:00Z", "start": "2017-11-18T19:00:00Z",
"end": "2017-11-19T04:30:00Z", "end": "2017-11-19T04:30:00Z",
@ -380,8 +352,7 @@
{ {
"model": "core.sleep", "model": "core.sleep",
"pk": 4, "pk": 4,
"fields": "fields": {
{
"child": 1, "child": 1,
"start": "2017-11-19T08:00:00Z", "start": "2017-11-19T08:00:00Z",
"end": "2017-11-19T09:30:00Z", "end": "2017-11-19T09:30:00Z",
@ -390,11 +361,10 @@
"nap": true "nap": true
} }
}, },
{ {
"model": "core.temperature", "model": "core.temperature",
"pk": 1, "pk": 1,
"fields": "fields": {
{
"child": 1, "child": 1,
"temperature": 98.6, "temperature": 98.6,
"time": "2017-11-17T17:52:00Z", "time": "2017-11-17T17:52:00Z",
@ -404,8 +374,7 @@
{ {
"model": "core.timer", "model": "core.timer",
"pk": 1, "pk": 1,
"fields": "fields": {
{
"name": "Fake timer", "name": "Fake timer",
"start": "2017-11-18T04:30:00Z", "start": "2017-11-18T04:30:00Z",
"user": 1 "user": 1
@ -414,8 +383,7 @@
{ {
"model": "core.tummytime", "model": "core.tummytime",
"pk": 1, "pk": 1,
"fields": "fields": {
{
"child": 1, "child": 1,
"start": "2017-11-18T15:00:00Z", "start": "2017-11-18T15:00:00Z",
"end": "2017-11-18T15:03:00Z", "end": "2017-11-18T15:03:00Z",
@ -426,8 +394,7 @@
{ {
"model": "core.tummytime", "model": "core.tummytime",
"pk": 2, "pk": 2,
"fields": "fields": {
{
"child": 1, "child": 1,
"start": "2017-11-18T17:15:30Z", "start": "2017-11-18T17:15:30Z",
"end": "2017-11-18T17:16:45Z", "end": "2017-11-18T17:16:45Z",
@ -438,8 +405,7 @@
{ {
"model": "core.tummytime", "model": "core.tummytime",
"pk": 3, "pk": 3,
"fields": "fields": {
{
"child": 1, "child": 1,
"start": "2017-11-18T20:30:00Z", "start": "2017-11-18T20:30:00Z",
"end": "2017-11-18T20:30:45Z", "end": "2017-11-18T20:30:45Z",
@ -450,8 +416,7 @@
{ {
"model": "core.weight", "model": "core.weight",
"pk": 1, "pk": 1,
"fields": "fields": {
{
"child": 1, "child": 1,
"weight": 8.5, "weight": 8.5,
"date": "2017-11-11" "date": "2017-11-11"
@ -460,8 +425,7 @@
{ {
"model": "core.weight", "model": "core.weight",
"pk": 2, "pk": 2,
"fields": "fields": {
{
"child": 1, "child": 1,
"weight": 9.5, "weight": 9.5,
"date": "2017-11-18", "date": "2017-11-18",
@ -471,8 +435,7 @@
{ {
"model": "core.height", "model": "core.height",
"pk": 1, "pk": 1,
"fields": "fields": {
{
"child": 1, "child": 1,
"height": 9.5, "height": 9.5,
"date": "2017-11-11" "date": "2017-11-11"
@ -481,8 +444,7 @@
{ {
"model": "core.height", "model": "core.height",
"pk": 2, "pk": 2,
"fields": "fields": {
{
"child": 1, "child": 1,
"height": 10.5, "height": 10.5,
"date": "2017-11-18", "date": "2017-11-18",
@ -492,8 +454,7 @@
{ {
"model": "core.headcircumference", "model": "core.headcircumference",
"pk": 1, "pk": 1,
"fields": "fields": {
{
"child": 1, "child": 1,
"head_circumference": 5.5, "head_circumference": 5.5,
"date": "2017-11-11" "date": "2017-11-11"
@ -502,8 +463,7 @@
{ {
"model": "core.headcircumference", "model": "core.headcircumference",
"pk": 2, "pk": 2,
"fields": "fields": {
{
"child": 1, "child": 1,
"head_circumference": 6.5, "head_circumference": 6.5,
"date": "2017-11-18", "date": "2017-11-18",
@ -513,8 +473,7 @@
{ {
"model": "core.bmi", "model": "core.bmi",
"pk": 1, "pk": 1,
"fields": "fields": {
{
"child": 1, "child": 1,
"bmi": 25.5, "bmi": 25.5,
"date": "2017-11-11" "date": "2017-11-11"
@ -523,8 +482,7 @@
{ {
"model": "core.bmi", "model": "core.bmi",
"pk": 2, "pk": 2,
"fields": "fields": {
{
"child": 1, "child": 1,
"bmi": 26.5, "bmi": 26.5,
"date": "2017-11-18", "date": "2017-11-18",
@ -534,8 +492,7 @@
{ {
"model": "core.tag", "model": "core.tag",
"pk": 1, "pk": 1,
"fields": "fields": {
{
"name": "a name", "name": "a name",
"slug": "a-name", "slug": "a-name",
"color": "#FF0000", "color": "#FF0000",

View File

@ -253,4 +253,4 @@
"src": "entypo" "src": "entypo"
} }
] ]
} }

View File

@ -1,5 +1,5 @@
if (typeof jQuery === 'undefined') { if (typeof jQuery === "undefined") {
throw new Error('Baby Buddy requires jQuery.') throw new Error("Baby Buddy requires jQuery.");
} }
/** /**
@ -9,37 +9,37 @@ if (typeof jQuery === 'undefined') {
* *
* @type {{}} * @type {{}}
*/ */
var BabyBuddy = function () { var BabyBuddy = (function () {
return {}; return {};
}(); })();
/** /**
* Pull to refresh. * Pull to refresh.
* *
* @type {{init: BabyBuddy.PullToRefresh.init, onRefresh: BabyBuddy.PullToRefresh.onRefresh}} * @type {{init: BabyBuddy.PullToRefresh.init, onRefresh: BabyBuddy.PullToRefresh.onRefresh}}
*/ */
BabyBuddy.PullToRefresh = function(ptr) { BabyBuddy.PullToRefresh = (function (ptr) {
return { return {
init: function () { init: function () {
ptr.init({ ptr.init({
mainElement: 'body', mainElement: "body",
onRefresh: this.onRefresh onRefresh: this.onRefresh,
}); });
}, },
onRefresh: function() { onRefresh: function () {
window.location.reload(); window.location.reload();
} },
}; };
}(PullToRefresh); })(PullToRefresh);
/** /**
* Fix for duplicate form submission from double pressing submit * Fix for duplicate form submission from double pressing submit
*/ */
function preventDoubleSubmit() { function preventDoubleSubmit() {
return false; return false;
} }
$('form').off("submit", preventDoubleSubmit); $("form").off("submit", preventDoubleSubmit);
$("form").on("submit", function() { $("form").on("submit", function () {
$(this).on("submit", preventDoubleSubmit); $(this).on("submit", preventDoubleSubmit);
}); });

View File

@ -1,354 +1,379 @@
(function() { (function () {
/** /**
* Parse a string as hexadecimal number * Parse a string as hexadecimal number
*/ */
function hexParse(x) { function hexParse(x) {
return parseInt(x, 16); return parseInt(x, 16);
}
/**
* Get the contrasting color for any hex color
*
* Sourced from: https://vanillajstoolkit.com/helpers/getcontrast/
* - Modified with slightly softer colors
* (c) 2021 Chris Ferdinandi, MIT License, https://gomakethings.com
* Derived from work by Brian Suda, https://24ways.org/2010/calculating-color-contrast/
* @param {String} A hexcolor value
* @return {String} The contrasting color (black or white)
*/
function computeComplementaryColor(hexcolor) {
// If a leading # is provided, remove it
if (hexcolor.slice(0, 1) === "#") {
hexcolor = hexcolor.slice(1);
} }
/** // If a three-character hexcode, make six-character
* Get the contrasting color for any hex color if (hexcolor.length === 3) {
* hexcolor = hexcolor
* Sourced from: https://vanillajstoolkit.com/helpers/getcontrast/ .split("")
* - Modified with slightly softer colors .map(function (hex) {
* (c) 2021 Chris Ferdinandi, MIT License, https://gomakethings.com return hex + hex;
* Derived from work by Brian Suda, https://24ways.org/2010/calculating-color-contrast/ })
* @param {String} A hexcolor value .join("");
* @return {String} The contrasting color (black or white)
*/
function computeComplementaryColor(hexcolor) {
// If a leading # is provided, remove it
if (hexcolor.slice(0, 1) === '#') {
hexcolor = hexcolor.slice(1);
}
// If a three-character hexcode, make six-character
if (hexcolor.length === 3) {
hexcolor = hexcolor.split('').map(function (hex) {
return hex + hex;
}).join('');
}
// Convert to RGB value
let r = parseInt(hexcolor.substr(0,2),16);
let g = parseInt(hexcolor.substr(2,2),16);
let b = parseInt(hexcolor.substr(4,2),16);
// Get YIQ ratio
let yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000;
// Check contrast
return (yiq >= 128) ? '#101010' : '#EFEFEF';
} }
// CSRF token should always be present because it is auto-included with // Convert to RGB value
// every tag-editor widget let r = parseInt(hexcolor.substr(0, 2), 16);
const CSRF_TOKEN = document.querySelector('input[name="csrfmiddlewaretoken"]').value; let g = parseInt(hexcolor.substr(2, 2), 16);
let b = parseInt(hexcolor.substr(4, 2), 16);
function doReq(method, uri, data, success, fail) { // Get YIQ ratio
// TODO: prefer jQuery based requests for now let yiq = (r * 299 + g * 587 + b * 114) / 1000;
const req = new XMLHttpRequest(); // Check contrast
req.addEventListener('load', () => { return yiq >= 128 ? "#101010" : "#EFEFEF";
if ((req.status >= 200) && (req.status < 300)) { }
success(req.responseText, req);
} else {
fail(req.responseText, req);
}
});
for (const name of ["error", "timeout", "abort"]) {
req.addEventListener(name, () => {
fail(req.responseText, req);
});
}
req.timeout = 20000;
req.open(method, uri); // CSRF token should always be present because it is auto-included with
req.setRequestHeader("Content-Type", "application/json"); // every tag-editor widget
req.setRequestHeader("Accept", "application/json"); const CSRF_TOKEN = document.querySelector(
req.setRequestHeader("X-CSRFTOKEN", CSRF_TOKEN); 'input[name="csrfmiddlewaretoken"]',
req.send(data); ).value;
}
/** function doReq(method, uri, data, success, fail) {
* Base class allowing generic operations on the tag lists, like: // TODO: prefer jQuery based requests for now
*
* - Adding tags to a tag list
* - Updating or creating new tags with a set name and color
* - Controlling the error modal
*/
class TaggingBase {
constructor(widget) {
this.prototype = widget.querySelector('.prototype-tag');
this.listeners = [];
this.modalElement = widget.querySelector('.tag-editor-error-modal'); const req = new XMLHttpRequest();
this.modalBodyNode = this.modalElement.querySelector('.modal-body'); req.addEventListener("load", () => {
if (req.status >= 200 && req.status < 300) {
// Clean whitespace text nodes between spans success(req.responseText, req);
for (const n of this.modalBodyNode.childNodes) { } else {
if (n.nodeType === Node.TEXT_NODE) { fail(req.responseText, req);
this.modalBodyNode.removeChild(n); }
}
}
}
showModal(msg) {
const selectedMessage = this.modalBodyNode.querySelector(`span[data-message='${msg}']`);
if (!selectedMessage) {
selectedMessage = this.modalBodyNode.childNodes[0];
}
for (const n of this.modalBodyNode.childNodes) {
n.classList.add('d-none');
}
selectedMessage.classList.remove('d-none');
jQuery(this.modalElement).modal('show');
}
addTagListUpdatedListener(c) {
this.listeners.push(c);
}
callTagListUpdatedListeners() {
for (const l of this.listeners) {
l();
}
}
updateTag(tag, name, color, actionSymbol) {
const actionTextNode = tag.querySelector('.add-remove-icon').childNodes[0];
name = name || tag.getAttribute("data-value");
color = color || tag.getAttribute("data-color");
actionSymbol = actionSymbol || actionTextNode.textContent;
tag.childNodes[0].textContent = name;
tag.setAttribute("data-value", name);
tag.setAttribute("data-color", color);
const textColor = computeComplementaryColor(color);
tag.setAttribute('style', `background-color: ${color}; color: ${textColor};`);
actionTextNode.textContent = actionSymbol;
}
createNewTag(name, color, actionSymbol) {
const tag = this.prototype.cloneNode(true);
tag.classList.remove("prototype-tag");
tag.classList.add("tag");
this.updateTag(tag, name, color, actionSymbol);
return tag;
}
insertTag(list, tag) {
list.appendChild(tag);
this.callTagListUpdatedListeners();
}
};
/**
* Handler for the edit field allowing to dynamically create new tags.
*
* Handles user inputs for the editor. Calls the 'onInsertNewTag' callback
* when the creation of a new tag has been requested. All backend handling
* like guareteening that the requested tag exists is handled by this class,
* the only task left is to add the new tag to the tags-list when
* 'onInsertNewTag' is called.
*/
class AddNewTagControl {
/**
* @param widget
* The root DOM element of the widget
* @param taggingBase
* Reference to a common TaggingBase class to be used by this widget
* @param onInsertNewTag
* Callback that is called when a new tag should be added to the
* tags widget.
*/
constructor(widget, taggingBase, onInsertNewTag) {
this.widget = widget;
this.taggingBase = taggingBase;
this.apiTagsUrl = widget.getAttribute('data-tags-url');
this.createTagInputs = widget.querySelector('.create-tag-inputs');
this.addTagInput = this.createTagInputs.querySelector('input[type="text"]');
this.addTagButton = this.createTagInputs.querySelector('#add-tag');
this.addTagInput.value = "";
this.onInsertNewTag = onInsertNewTag;
this.addTagButton.addEventListener('click', () => this.onCreateTagClicked());
this.addTagInput.addEventListener('keydown', (e) => {
const key = e.key.toLowerCase();
if (key === "enter") {
e.preventDefault();
this.onCreateTagClicked();
}
});
}
/**
* Callback called when the "Add" button of the add-tag input is
* clicked or enter is pressed in the editor.
*/
onCreateTagClicked() {
// TODO: Make promise based
const tagName = this.addTagInput.value.trim();
const uriTagName = encodeURIComponent(tagName);
const fail = (msg) => {
this.addTagInput.select();
this.taggingBase.showModal(msg || "generic");
};
if (!tagName) {
fail('invalid-tag-name');
return;
}
const addTag = (name, color) => {
const tag = this.taggingBase.createNewTag(name, color, "-");
this.addTagInput.value = "";
this.onInsertNewTag(tag);
};
const data = JSON.stringify({
'name': this.addTagInput.value
});
doReq("GET", `${this.apiTagsUrl}?name=${uriTagName}`, null,
(text) => {
const json = JSON.parse(text);
if (json.count) {
const tagJson = json.results[0];
addTag(tagJson.name, tagJson.color);
} else {
doReq("POST", this.apiTagsUrl, data,
(text) => {
const tagJson = JSON.parse(text);
addTag(tagJson.name, tagJson.color);
}, () => fail("tag-creation-failed")
);
}
}, () => fail("tag-checking-failed")
);
}
};
/**
* JavaScript implementation for the tags editor.
*
* This class uses TaggingBase and AddNewTagControl to provide the custom
* tag editor controls. This mainly consists of updating the hidden
* input values with the current list of tags and adding/removing
* tags from the current-tags- or recently-used-lists.
*/
class TagsEditor {
/**
* @param tagEditorRoot
* The root DOM element of the widget.
*/
constructor(tagEditorRoot) {
this.widget = tagEditorRoot;
this.taggingBase = new TaggingBase(this.widget);
this.addTagControl = new AddNewTagControl(
this.widget, this.taggingBase, (t) => this.insertNewTag(t)
);
this.currentTags = this.widget.querySelector('.current_tags');
this.newTags = this.widget.querySelector('.new-tags');
this.inputElement = this.widget.querySelector('input[type="hidden"]');
for (const tag of this.newTags.querySelectorAll(".tag")) {
this.configureAddTag(tag);
}
for (const tag of this.currentTags.querySelectorAll(".tag")) {
this.configureRemoveTag(tag);
}
this.updateInputList();
this.taggingBase.addTagListUpdatedListener(
() => this.updateInputList()
);
}
/**
* Insert a new tag into the "current tag" list.
*
* Makes sure that no duplicates are present in the widget before adding
* the new tag. If a duplicate is found, the old tag is removed before
* the new one is added.
*/
insertNewTag(tag) {
const name = tag.getAttribute("data-value");
const oldTag = this.widget.querySelector(`span[data-value="${name}"]`);
if (oldTag) {
oldTag.parentNode.removeChild(oldTag);
}
this.taggingBase.insertTag(this.currentTags, tag);
this.configureRemoveTag(tag);
}
/**
* Registeres a click-callback for a given node.
*
* The callback chain-calls another callback "onClicked" after
* moving the clicked tag from the old tag-list to a new tag list.
*/
registerNewCallback(tag, newParent, onClicked) {
function callback(event) {
tag.parentNode.removeChild(tag);
this.taggingBase.insertTag(newParent, tag);
tag.removeEventListener('click', callback);
onClicked(tag);
}
tag.addEventListener('click', callback.bind(this));
}
/**
* Updates the value of the hidden input element.
*
* Sets the value from the list of tags added to the currentTags
* DOM element.
*/
updateInputList() {
const names = [];
for (const tag of this.currentTags.querySelectorAll(".tag")) {
const name = tag.getAttribute("data-value");
names.push(`"${name}"`);
}
this.inputElement.value = names.join(",");
}
/**
* Configure a tag-DOM element as a "add tag" button.
*/
configureAddTag(tag) {
this.taggingBase.updateTag(tag, null, null, "+");
this.registerNewCallback(tag, this.currentTags, () => this.configureRemoveTag(tag));
this.updateInputList();
}
/**
* Configure a tag-DOM element as a "remove tag" button.
*/
configureRemoveTag(tag) {
this.taggingBase.updateTag(tag, null, null, "-");
this.registerNewCallback(tag, this.newTags, () => this.configureAddTag(tag));
this.updateInputList();
}
};
window.addEventListener('load', () => {
for (const el of document.querySelectorAll('.babybuddy-tags-editor')) {
new TagsEditor(el);
}
}); });
})(); for (const name of ["error", "timeout", "abort"]) {
req.addEventListener(name, () => {
fail(req.responseText, req);
});
}
req.timeout = 20000;
req.open(method, uri);
req.setRequestHeader("Content-Type", "application/json");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("X-CSRFTOKEN", CSRF_TOKEN);
req.send(data);
}
/**
* Base class allowing generic operations on the tag lists, like:
*
* - Adding tags to a tag list
* - Updating or creating new tags with a set name and color
* - Controlling the error modal
*/
class TaggingBase {
constructor(widget) {
this.prototype = widget.querySelector(".prototype-tag");
this.listeners = [];
this.modalElement = widget.querySelector(".tag-editor-error-modal");
this.modalBodyNode = this.modalElement.querySelector(".modal-body");
// Clean whitespace text nodes between spans
for (const n of this.modalBodyNode.childNodes) {
if (n.nodeType === Node.TEXT_NODE) {
this.modalBodyNode.removeChild(n);
}
}
}
showModal(msg) {
const selectedMessage = this.modalBodyNode.querySelector(
`span[data-message='${msg}']`,
);
if (!selectedMessage) {
selectedMessage = this.modalBodyNode.childNodes[0];
}
for (const n of this.modalBodyNode.childNodes) {
n.classList.add("d-none");
}
selectedMessage.classList.remove("d-none");
jQuery(this.modalElement).modal("show");
}
addTagListUpdatedListener(c) {
this.listeners.push(c);
}
callTagListUpdatedListeners() {
for (const l of this.listeners) {
l();
}
}
updateTag(tag, name, color, actionSymbol) {
const actionTextNode =
tag.querySelector(".add-remove-icon").childNodes[0];
name = name || tag.getAttribute("data-value");
color = color || tag.getAttribute("data-color");
actionSymbol = actionSymbol || actionTextNode.textContent;
tag.childNodes[0].textContent = name;
tag.setAttribute("data-value", name);
tag.setAttribute("data-color", color);
const textColor = computeComplementaryColor(color);
tag.setAttribute(
"style",
`background-color: ${color}; color: ${textColor};`,
);
actionTextNode.textContent = actionSymbol;
}
createNewTag(name, color, actionSymbol) {
const tag = this.prototype.cloneNode(true);
tag.classList.remove("prototype-tag");
tag.classList.add("tag");
this.updateTag(tag, name, color, actionSymbol);
return tag;
}
insertTag(list, tag) {
list.appendChild(tag);
this.callTagListUpdatedListeners();
}
}
/**
* Handler for the edit field allowing to dynamically create new tags.
*
* Handles user inputs for the editor. Calls the 'onInsertNewTag' callback
* when the creation of a new tag has been requested. All backend handling
* like guareteening that the requested tag exists is handled by this class,
* the only task left is to add the new tag to the tags-list when
* 'onInsertNewTag' is called.
*/
class AddNewTagControl {
/**
* @param widget
* The root DOM element of the widget
* @param taggingBase
* Reference to a common TaggingBase class to be used by this widget
* @param onInsertNewTag
* Callback that is called when a new tag should be added to the
* tags widget.
*/
constructor(widget, taggingBase, onInsertNewTag) {
this.widget = widget;
this.taggingBase = taggingBase;
this.apiTagsUrl = widget.getAttribute("data-tags-url");
this.createTagInputs = widget.querySelector(".create-tag-inputs");
this.addTagInput =
this.createTagInputs.querySelector('input[type="text"]');
this.addTagButton = this.createTagInputs.querySelector("#add-tag");
this.addTagInput.value = "";
this.onInsertNewTag = onInsertNewTag;
this.addTagButton.addEventListener("click", () =>
this.onCreateTagClicked(),
);
this.addTagInput.addEventListener("keydown", (e) => {
const key = e.key.toLowerCase();
if (key === "enter") {
e.preventDefault();
this.onCreateTagClicked();
}
});
}
/**
* Callback called when the "Add" button of the add-tag input is
* clicked or enter is pressed in the editor.
*/
onCreateTagClicked() {
// TODO: Make promise based
const tagName = this.addTagInput.value.trim();
const uriTagName = encodeURIComponent(tagName);
const fail = (msg) => {
this.addTagInput.select();
this.taggingBase.showModal(msg || "generic");
};
if (!tagName) {
fail("invalid-tag-name");
return;
}
const addTag = (name, color) => {
const tag = this.taggingBase.createNewTag(name, color, "-");
this.addTagInput.value = "";
this.onInsertNewTag(tag);
};
const data = JSON.stringify({
name: this.addTagInput.value,
});
doReq(
"GET",
`${this.apiTagsUrl}?name=${uriTagName}`,
null,
(text) => {
const json = JSON.parse(text);
if (json.count) {
const tagJson = json.results[0];
addTag(tagJson.name, tagJson.color);
} else {
doReq(
"POST",
this.apiTagsUrl,
data,
(text) => {
const tagJson = JSON.parse(text);
addTag(tagJson.name, tagJson.color);
},
() => fail("tag-creation-failed"),
);
}
},
() => fail("tag-checking-failed"),
);
}
}
/**
* JavaScript implementation for the tags editor.
*
* This class uses TaggingBase and AddNewTagControl to provide the custom
* tag editor controls. This mainly consists of updating the hidden
* input values with the current list of tags and adding/removing
* tags from the current-tags- or recently-used-lists.
*/
class TagsEditor {
/**
* @param tagEditorRoot
* The root DOM element of the widget.
*/
constructor(tagEditorRoot) {
this.widget = tagEditorRoot;
this.taggingBase = new TaggingBase(this.widget);
this.addTagControl = new AddNewTagControl(
this.widget,
this.taggingBase,
(t) => this.insertNewTag(t),
);
this.currentTags = this.widget.querySelector(".current_tags");
this.newTags = this.widget.querySelector(".new-tags");
this.inputElement = this.widget.querySelector('input[type="hidden"]');
for (const tag of this.newTags.querySelectorAll(".tag")) {
this.configureAddTag(tag);
}
for (const tag of this.currentTags.querySelectorAll(".tag")) {
this.configureRemoveTag(tag);
}
this.updateInputList();
this.taggingBase.addTagListUpdatedListener(() => this.updateInputList());
}
/**
* Insert a new tag into the "current tag" list.
*
* Makes sure that no duplicates are present in the widget before adding
* the new tag. If a duplicate is found, the old tag is removed before
* the new one is added.
*/
insertNewTag(tag) {
const name = tag.getAttribute("data-value");
const oldTag = this.widget.querySelector(`span[data-value="${name}"]`);
if (oldTag) {
oldTag.parentNode.removeChild(oldTag);
}
this.taggingBase.insertTag(this.currentTags, tag);
this.configureRemoveTag(tag);
}
/**
* Registeres a click-callback for a given node.
*
* The callback chain-calls another callback "onClicked" after
* moving the clicked tag from the old tag-list to a new tag list.
*/
registerNewCallback(tag, newParent, onClicked) {
function callback(event) {
tag.parentNode.removeChild(tag);
this.taggingBase.insertTag(newParent, tag);
tag.removeEventListener("click", callback);
onClicked(tag);
}
tag.addEventListener("click", callback.bind(this));
}
/**
* Updates the value of the hidden input element.
*
* Sets the value from the list of tags added to the currentTags
* DOM element.
*/
updateInputList() {
const names = [];
for (const tag of this.currentTags.querySelectorAll(".tag")) {
const name = tag.getAttribute("data-value");
names.push(`"${name}"`);
}
this.inputElement.value = names.join(",");
}
/**
* Configure a tag-DOM element as a "add tag" button.
*/
configureAddTag(tag) {
this.taggingBase.updateTag(tag, null, null, "+");
this.registerNewCallback(tag, this.currentTags, () =>
this.configureRemoveTag(tag),
);
this.updateInputList();
}
/**
* Configure a tag-DOM element as a "remove tag" button.
*/
configureRemoveTag(tag) {
this.taggingBase.updateTag(tag, null, null, "-");
this.registerNewCallback(tag, this.newTags, () =>
this.configureAddTag(tag),
);
this.updateInputList();
}
}
window.addEventListener("load", () => {
for (const el of document.querySelectorAll(".babybuddy-tags-editor")) {
new TagsEditor(el);
}
});
})();

View File

@ -1,21 +1,21 @@
{ {
"name": "Baby Buddy", "name": "Baby Buddy",
"short_name": "Baby Buddy", "short_name": "Baby Buddy",
"icons": [ "icons": [
{ {
"src": "android-chrome-192x192.png?v=20211218", "src": "android-chrome-192x192.png?v=20211218",
"sizes": "192x192", "sizes": "192x192",
"type": "image/png" "type": "image/png"
}, },
{ {
"src": "android-chrome-512x512.png?v=20211218", "src": "android-chrome-512x512.png?v=20211218",
"sizes": "512x512", "sizes": "512x512",
"type": "image/png" "type": "image/png"
} }
], ],
"lang": "en-US", "lang": "en-US",
"start_url": "/", "start_url": "/",
"display": "standalone", "display": "standalone",
"theme_color": "#37abe9", "theme_color": "#37abe9",
"background_color": "#212529" "background_color": "#212529"
} }

View File

@ -6,98 +6,96 @@
* * timer-minutes * * timer-minutes
* * timer-hours * * timer-hours
*/ */
BabyBuddy.Timer = function ($) { BabyBuddy.Timer = (function ($) {
var runIntervalId = null; var runIntervalId = null;
var timerId = null; var timerId = null;
var timerElement = null; var timerElement = null;
var lastUpdate = new Date(); var lastUpdate = new Date();
var hidden = null; var hidden = null;
var Timer = { var Timer = {
run: function(timer_id, element_id) { run: function (timer_id, element_id) {
timerId = timer_id; timerId = timer_id;
timerElement = $('#' + element_id); timerElement = $("#" + element_id);
if (timerElement.length === 0) { if (timerElement.length === 0) {
console.error('BBTimer: Timer element not found.'); console.error("BBTimer: Timer element not found.");
return false; return false;
} }
if (timerElement.find('.timer-seconds').length === 0 if (
|| timerElement.find('.timer-minutes').length === 0 timerElement.find(".timer-seconds").length === 0 ||
|| timerElement.find('.timer-hours').length === 0) { timerElement.find(".timer-minutes").length === 0 ||
console.error('BBTimer: Element does not contain expected children.'); timerElement.find(".timer-hours").length === 0
return false; ) {
} console.error("BBTimer: Element does not contain expected children.");
return false;
}
runIntervalId = setInterval(this.tick, 1000); runIntervalId = setInterval(this.tick, 1000);
// If the page just came in to view, update the timer data with the // If the page just came in to view, update the timer data with the
// current actual duration. This will (potentially) help mobile // current actual duration. This will (potentially) help mobile
// phones that lock with the timer page open. // phones that lock with the timer page open.
if (typeof document.hidden !== "undefined") { if (typeof document.hidden !== "undefined") {
hidden = "hidden"; hidden = "hidden";
} } else if (typeof document.msHidden !== "undefined") {
else if (typeof document.msHidden !== "undefined") { hidden = "msHidden";
hidden = "msHidden"; } else if (typeof document.webkitHidden !== "undefined") {
} hidden = "webkitHidden";
else if (typeof document.webkitHidden !== "undefined") { }
hidden = "webkitHidden"; window.addEventListener("focus", Timer.handleVisibilityChange, false);
} },
window.addEventListener('focus', Timer.handleVisibilityChange, false);
},
handleVisibilityChange: function() { handleVisibilityChange: function () {
if (!document[hidden] && (new Date()) - lastUpdate > 1) { if (!document[hidden] && new Date() - lastUpdate > 1) {
Timer.update(); Timer.update();
} }
}, },
tick: function() { tick: function () {
var s = timerElement.find('.timer-seconds'); var s = timerElement.find(".timer-seconds");
var seconds = Number(s.text()); var seconds = Number(s.text());
if (seconds < 59) { if (seconds < 59) {
s.text(seconds + 1); s.text(seconds + 1);
return; return;
} } else {
else { s.text(0);
s.text(0); }
}
var m = timerElement.find('.timer-minutes'); var m = timerElement.find(".timer-minutes");
var minutes = Number(m.text()); var minutes = Number(m.text());
if (minutes < 59) { if (minutes < 59) {
m.text(minutes + 1); m.text(minutes + 1);
return; return;
} } else {
else { m.text(0);
m.text(0); }
}
var h = timerElement.find('.timer-hours'); var h = timerElement.find(".timer-hours");
var hours = Number(h.text()); var hours = Number(h.text());
h.text(hours + 1); h.text(hours + 1);
}, },
update: function() { update: function () {
$.get('/api/timers/' + timerId + '/', function(data) { $.get("/api/timers/" + timerId + "/", function (data) {
if (data && 'duration' in data) { if (data && "duration" in data) {
clearInterval(runIntervalId); clearInterval(runIntervalId);
var duration = data.duration.split(/[\s:.]/) var duration = data.duration.split(/[\s:.]/);
if (duration.length === 5) { if (duration.length === 5) {
duration[0] = parseInt(duration[0]) * 24 + parseInt(duration[1]); duration[0] = parseInt(duration[0]) * 24 + parseInt(duration[1]);
duration[1] = duration[2]; duration[1] = duration[2];
duration[2] = duration[3]; duration[2] = duration[3];
} }
timerElement.find('.timer-hours').text(parseInt(duration[0])); timerElement.find(".timer-hours").text(parseInt(duration[0]));
timerElement.find('.timer-minutes').text(parseInt(duration[1])); timerElement.find(".timer-minutes").text(parseInt(duration[1]));
timerElement.find('.timer-seconds').text(parseInt(duration[2])); timerElement.find(".timer-seconds").text(parseInt(duration[2]));
lastUpdate = new Date() lastUpdate = new Date();
runIntervalId = setInterval(Timer.tick, 1000); runIntervalId = setInterval(Timer.tick, 1000);
}
});
} }
}; });
},
};
return Timer; return Timer;
}(jQuery); })(jQuery);

View File

@ -3,54 +3,61 @@
* Provides a "watch" function to update the dashboard at one minute intervals * Provides a "watch" function to update the dashboard at one minute intervals
* and/or on visibility state changes. * and/or on visibility state changes.
*/ */
BabyBuddy.Dashboard = function ($) { BabyBuddy.Dashboard = (function ($) {
var runIntervalId = null; var runIntervalId = null;
var dashboardElement = null; var dashboardElement = null;
var hidden = null; var hidden = null;
var Dashboard = { var Dashboard = {
watch: function(element_id, refresh_rate) { watch: function (element_id, refresh_rate) {
dashboardElement = $('#' + element_id); dashboardElement = $("#" + element_id);
if (dashboardElement.length == 0) { if (dashboardElement.length == 0) {
console.error('Baby Buddy: Dashboard element not found.'); console.error("Baby Buddy: Dashboard element not found.");
return false; return false;
} }
if (typeof document.hidden !== "undefined") { if (typeof document.hidden !== "undefined") {
hidden = "hidden"; hidden = "hidden";
} } else if (typeof document.msHidden !== "undefined") {
else if (typeof document.msHidden !== "undefined") { hidden = "msHidden";
hidden = "msHidden"; } else if (typeof document.webkitHidden !== "undefined") {
} hidden = "webkitHidden";
else if (typeof document.webkitHidden !== "undefined") { }
hidden = "webkitHidden";
}
if (typeof window.addEventListener === "undefined" || typeof document.hidden === "undefined") { if (
if (refresh_rate) { typeof window.addEventListener === "undefined" ||
runIntervalId = setInterval(this.update, refresh_rate); typeof document.hidden === "undefined"
} ) {
} if (refresh_rate) {
else { runIntervalId = setInterval(this.update, refresh_rate);
window.addEventListener('focus', Dashboard.handleVisibilityChange, false);
if (refresh_rate) {
runIntervalId = setInterval(Dashboard.handleVisibilityChange, refresh_rate);
}
}
},
handleVisibilityChange: function() {
if (!document[hidden]) {
Dashboard.update();
}
},
update: function() {
// TODO: Someday maybe update in place?
location.reload();
} }
}; } else {
window.addEventListener(
"focus",
Dashboard.handleVisibilityChange,
false,
);
if (refresh_rate) {
runIntervalId = setInterval(
Dashboard.handleVisibilityChange,
refresh_rate,
);
}
}
},
return Dashboard; handleVisibilityChange: function () {
}(jQuery); if (!document[hidden]) {
Dashboard.update();
}
},
update: function () {
// TODO: Someday maybe update in place?
location.reload();
},
};
return Dashboard;
})(jQuery);

View File

@ -1,89 +1,78 @@
const basePath = 'babybuddy/static/babybuddy/'; const basePath = "babybuddy/static/babybuddy/";
module.exports = { module.exports = {
basePath: basePath, basePath: basePath,
extrasConfig: { extrasConfig: {
fonts: { fonts: {
dest: basePath + 'font/', dest: basePath + "font/",
files: 'babybuddy/static_src/fontello/font/*' files: "babybuddy/static_src/fontello/font/*",
},
images: {
dest: basePath + 'img/',
files: '**/static_src/img/**/*'
},
logo: {
dest: basePath + 'logo/',
files: 'babybuddy/static_src/logo/**/*'
},
root: {
dest: basePath + 'root/',
files: 'babybuddy/static_src/root/*'
}
}, },
glyphFontConfig: { images: {
configFile: 'babybuddy/static_src/fontello/config.json', dest: basePath + "img/",
dest: 'babybuddy/static_src/fontello' files: "**/static_src/img/**/*",
}, },
scriptsConfig: { logo: {
dest: basePath + 'js/', dest: basePath + "logo/",
vendor: [ files: "babybuddy/static_src/logo/**/*",
'node_modules/pulltorefreshjs/dist/index.umd.js',
'node_modules/jquery/dist/jquery.js',
'node_modules/@popperjs/core/dist/umd/popper.js',
'node_modules/bootstrap/dist/js/bootstrap.js',
'node_modules/masonry-layout/dist/masonry.pkgd.js'
],
graph: [
'node_modules/plotly.js/dist/plotly-cartesian.js',
'node_modules/plotly.js/dist/plotly-locale-ca.js',
'node_modules/plotly.js/dist/plotly-locale-cs.js',
'node_modules/plotly.js/dist/plotly-locale-de.js',
'node_modules/plotly.js/dist/plotly-locale-da.js',
'node_modules/plotly.js/dist/plotly-locale-es.js',
'node_modules/plotly.js/dist/plotly-locale-fi.js',
'node_modules/plotly.js/dist/plotly-locale-fr.js',
'node_modules/plotly.js/dist/plotly-locale-hu.js',
'node_modules/plotly.js/dist/plotly-locale-it.js',
'node_modules/plotly.js/dist/plotly-locale-no.js',
'node_modules/plotly.js/dist/plotly-locale-nl.js',
'node_modules/plotly.js/dist/plotly-locale-pl.js',
'node_modules/plotly.js/dist/plotly-locale-pt-br.js',
'node_modules/plotly.js/dist/plotly-locale-pt-pt.js',
'node_modules/plotly.js/dist/plotly-locale-ru.js',
'node_modules/plotly.js/dist/plotly-locale-sv.js',
'node_modules/plotly.js/dist/plotly-locale-tr.js',
'node_modules/plotly.js/dist/plotly-locale-uk.js',
'node_modules/plotly.js/dist/plotly-locale-zh-cn.js',
],
app: [
'babybuddy/static_src/js/babybuddy.js',
'api/static_src/js/*.js',
'core/static_src/js/*.js',
'dashboard/static_src/js/*.js'
],
tags_editor: [
'babybuddy/static_src/js/tags_editor.js'
]
}, },
stylesConfig: { root: {
dest: basePath + 'css/', dest: basePath + "root/",
app: 'babybuddy/static_src/scss/babybuddy.scss', files: "babybuddy/static_src/root/*",
ignore: [
'babybuddy.scss'
]
}, },
testsConfig: { },
isolated: [ glyphFontConfig: {
'babybuddy.tests.tests_views.ViewsTestCase.test_password_reset' configFile: "babybuddy/static_src/fontello/config.json",
], dest: "babybuddy/static_src/fontello",
}, },
watchConfig: { scriptsConfig: {
scriptsGlob: [ dest: basePath + "js/",
'*/static_src/js/**/*.js', vendor: [
'!babybuddy/static/js/' "node_modules/pulltorefreshjs/dist/index.umd.js",
], "node_modules/jquery/dist/jquery.js",
stylesGlob: [ "node_modules/@popperjs/core/dist/umd/popper.js",
'*/static_src/scss/**/*.scss' "node_modules/bootstrap/dist/js/bootstrap.js",
] "node_modules/masonry-layout/dist/masonry.pkgd.js",
} ],
graph: [
"node_modules/plotly.js/dist/plotly-cartesian.js",
"node_modules/plotly.js/dist/plotly-locale-ca.js",
"node_modules/plotly.js/dist/plotly-locale-cs.js",
"node_modules/plotly.js/dist/plotly-locale-de.js",
"node_modules/plotly.js/dist/plotly-locale-da.js",
"node_modules/plotly.js/dist/plotly-locale-es.js",
"node_modules/plotly.js/dist/plotly-locale-fi.js",
"node_modules/plotly.js/dist/plotly-locale-fr.js",
"node_modules/plotly.js/dist/plotly-locale-hu.js",
"node_modules/plotly.js/dist/plotly-locale-it.js",
"node_modules/plotly.js/dist/plotly-locale-no.js",
"node_modules/plotly.js/dist/plotly-locale-nl.js",
"node_modules/plotly.js/dist/plotly-locale-pl.js",
"node_modules/plotly.js/dist/plotly-locale-pt-br.js",
"node_modules/plotly.js/dist/plotly-locale-pt-pt.js",
"node_modules/plotly.js/dist/plotly-locale-ru.js",
"node_modules/plotly.js/dist/plotly-locale-sv.js",
"node_modules/plotly.js/dist/plotly-locale-tr.js",
"node_modules/plotly.js/dist/plotly-locale-uk.js",
"node_modules/plotly.js/dist/plotly-locale-zh-cn.js",
],
app: [
"babybuddy/static_src/js/babybuddy.js",
"api/static_src/js/*.js",
"core/static_src/js/*.js",
"dashboard/static_src/js/*.js",
],
tags_editor: ["babybuddy/static_src/js/tags_editor.js"],
},
stylesConfig: {
dest: basePath + "css/",
app: "babybuddy/static_src/scss/babybuddy.scss",
ignore: ["babybuddy.scss"],
},
testsConfig: {
isolated: ["babybuddy.tests.tests_views.ViewsTestCase.test_password_reset"],
},
watchConfig: {
scriptsGlob: ["*/static_src/js/**/*.js", "!babybuddy/static/js/"],
stylesGlob: ["*/static_src/scss/**/*.scss"],
},
}; };

View File

@ -345,7 +345,7 @@ gulp.task("runserver", function (cb) {
if (parameters[i] === "runserver") { if (parameters[i] === "runserver") {
delete parameters[i]; delete parameters[i];
} else if (parameters[i] === "--ip") { } else if (parameters[i] === "--ip") {
/* "--ip" parameter to set the server IP address. */ /* "--ip" parameter to set the server IP address. */
command.push(parameters[i + 1]); command.push(parameters[i + 1]);
delete parameters[i]; delete parameters[i];
delete parameters[i + 1]; delete parameters[i + 1];