mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-11 16:24:11 +01:00
Frontend: Reformat src/common/*.js with ESLint & Prettier
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
@@ -12,9 +12,7 @@ export function processAlbumSelection(selectedAlbums, availableAlbums) {
|
||||
selectedAlbums.forEach((item) => {
|
||||
// If it's a string, try to match it with existing albums
|
||||
if (typeof item === "string" && item.trim().length > 0) {
|
||||
const matchedAlbum = availableAlbums.find(
|
||||
(album) => album.Title && album.Title.toLowerCase() === item.trim().toLowerCase()
|
||||
);
|
||||
const matchedAlbum = availableAlbums.find((album) => album.Title && album.Title.toLowerCase() === item.trim().toLowerCase());
|
||||
|
||||
if (matchedAlbum && !seenUids.has(matchedAlbum.UID)) {
|
||||
// Replace string with actual album object
|
||||
|
||||
@@ -241,12 +241,7 @@ export default class Config {
|
||||
.filter((m) => m.UID === values.UID)
|
||||
.forEach((m) => {
|
||||
for (let key in values) {
|
||||
if (
|
||||
key !== "UID" &&
|
||||
values.hasOwnProperty(key) &&
|
||||
values[key] != null &&
|
||||
typeof values[key] !== "object"
|
||||
) {
|
||||
if (key !== "UID" && values.hasOwnProperty(key) && values[key] != null && typeof values[key] !== "object") {
|
||||
m[key] = values[key];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,11 +102,7 @@ export class Form {
|
||||
|
||||
// getOptions resolves the options array for select-style fields.
|
||||
getOptions(fieldName) {
|
||||
if (
|
||||
this.definition &&
|
||||
this.definition.hasOwnProperty(fieldName) &&
|
||||
this.definition[fieldName].hasOwnProperty("options")
|
||||
) {
|
||||
if (this.definition && this.definition.hasOwnProperty(fieldName) && this.definition[fieldName].hasOwnProperty("options")) {
|
||||
return this.definition[fieldName].options;
|
||||
}
|
||||
|
||||
@@ -209,9 +205,7 @@ export class rules {
|
||||
return false;
|
||||
}
|
||||
|
||||
return /^[A-Za-z0-9.!#$%&'*+/=?^_`{|}~-]+@[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/.test(
|
||||
v
|
||||
);
|
||||
return /^[A-Za-z0-9.!#$%&'*+/=?^_`{|}~-]+@[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/.test(v);
|
||||
}
|
||||
|
||||
// isUrl validates strings by length and URL parsing.
|
||||
@@ -260,10 +254,7 @@ export class rules {
|
||||
// email returns Vuetify rule callbacks for email validation.
|
||||
static email(required) {
|
||||
if (required) {
|
||||
return [
|
||||
(v) => !!v || $gettext("This field is required"),
|
||||
(v) => !v || this.isEmail(v) || $gettext("Invalid address"),
|
||||
];
|
||||
return [(v) => !!v || $gettext("This field is required"), (v) => !v || this.isEmail(v) || $gettext("Invalid address")];
|
||||
} else {
|
||||
return [(v) => !v || this.isEmail(v) || $gettext("Invalid address")];
|
||||
}
|
||||
@@ -352,20 +343,14 @@ export class rules {
|
||||
(v) => this.maxLen(v, 2) || $gettext("Invalid country"),
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
(v) => this.minLen(v, 2) || $gettext("Invalid country"),
|
||||
(v) => this.maxLen(v, 2) || $gettext("Invalid country"),
|
||||
];
|
||||
return [(v) => this.minLen(v, 2) || $gettext("Invalid country"), (v) => this.maxLen(v, 2) || $gettext("Invalid country")];
|
||||
}
|
||||
}
|
||||
|
||||
// day validates day-of-month values between 1 and 31.
|
||||
static day(required) {
|
||||
if (required) {
|
||||
return [
|
||||
(v) => !!v || Number(v) < -1 || $gettext("This field is required"),
|
||||
(v) => this.isNumberRange(v, 1, 31) || $gettext("Invalid"),
|
||||
];
|
||||
return [(v) => !!v || Number(v) < -1 || $gettext("This field is required"), (v) => this.isNumberRange(v, 1, 31) || $gettext("Invalid")];
|
||||
} else {
|
||||
return [(v) => this.isNumberRange(v, 1, 31) || $gettext("Invalid")];
|
||||
}
|
||||
@@ -374,10 +359,7 @@ export class rules {
|
||||
// month validates month values between 1 and 12.
|
||||
static month(required) {
|
||||
if (required) {
|
||||
return [
|
||||
(v) => !!v || Number(v) < -1 || $gettext("This field is required"),
|
||||
(v) => this.isNumberRange(v, 1, 12) || $gettext("Invalid"),
|
||||
];
|
||||
return [(v) => !!v || Number(v) < -1 || $gettext("This field is required"), (v) => this.isNumberRange(v, 1, 12) || $gettext("Invalid")];
|
||||
} else {
|
||||
return [(v) => this.isNumberRange(v, 1, 12) || $gettext("Invalid")];
|
||||
}
|
||||
@@ -394,10 +376,7 @@ export class rules {
|
||||
}
|
||||
|
||||
if (required) {
|
||||
return [
|
||||
(v) => !!v || Number(v) < -1 || $gettext("This field is required"),
|
||||
(v) => this.isNumberRange(v, min, max) || $gettext("Invalid"),
|
||||
];
|
||||
return [(v) => !!v || Number(v) < -1 || $gettext("This field is required"), (v) => this.isNumberRange(v, min, max) || $gettext("Invalid")];
|
||||
} else {
|
||||
return [(v) => this.isNumberRange(v, min, max) || $gettext("Invalid")];
|
||||
}
|
||||
|
||||
@@ -75,10 +75,7 @@ export class Input {
|
||||
return InputInvalid;
|
||||
}
|
||||
|
||||
if (
|
||||
Math.abs(this.touches[0].screenX - ev.changedTouches[0].screenX) > 4 ||
|
||||
Math.abs(this.touches[0].screenY - ev.changedTouches[0].screenY) > 4
|
||||
) {
|
||||
if (Math.abs(this.touches[0].screenX - ev.changedTouches[0].screenX) > 4 || Math.abs(this.touches[0].screenY - ev.changedTouches[0].screenY) > 4) {
|
||||
return InputInvalid;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,13 +15,7 @@ const langFallbackDecorate = function (style, cfg) {
|
||||
for (let i = layers.length - 1; i >= 0; i--) {
|
||||
let layer = layers[i];
|
||||
if (
|
||||
!(
|
||||
lf[0] === "in" &&
|
||||
lfProp === "layout.text-field" &&
|
||||
layer.layout &&
|
||||
layer.layout["text-field"] &&
|
||||
lfValues.indexOf(layer.layout["text-field"]) >= 0
|
||||
)
|
||||
!(lf[0] === "in" && lfProp === "layout.text-field" && layer.layout && layer.layout["text-field"] && lfValues.indexOf(layer.layout["text-field"]) >= 0)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
@@ -95,27 +89,7 @@ maplibregl.Map.prototype.setLanguage = function (language, noAlt) {
|
||||
return;
|
||||
}
|
||||
|
||||
let isNonlatin =
|
||||
[
|
||||
"ar",
|
||||
"hy",
|
||||
"be",
|
||||
"bg",
|
||||
"zh",
|
||||
"ka",
|
||||
"el",
|
||||
"he",
|
||||
"ja",
|
||||
"ja_kana",
|
||||
"kn",
|
||||
"kk",
|
||||
"ko",
|
||||
"mk",
|
||||
"ru",
|
||||
"sr",
|
||||
"th",
|
||||
"uk",
|
||||
].indexOf(language) >= 0;
|
||||
let isNonlatin = ["ar", "hy", "be", "bg", "zh", "ka", "el", "he", "ja", "ja_kana", "kn", "kk", "ko", "mk", "ru", "sr", "th", "uk"].indexOf(language) >= 0;
|
||||
|
||||
let style = JSON.parse(JSON.stringify(this.styleUndecorated));
|
||||
let langCfg = {
|
||||
@@ -131,15 +105,12 @@ maplibregl.Map.prototype.setLanguage = function (language, noAlt) {
|
||||
],
|
||||
"decorators": [
|
||||
{
|
||||
"layout.text-field": isNonlatin
|
||||
? "{name:nonlatin}" + (noAlt ? "" : "\n{name:latin}")
|
||||
: "{name:latin}" + (noAlt ? "" : "\n{name:nonlatin}"),
|
||||
"layout.text-field": isNonlatin ? "{name:nonlatin}" + (noAlt ? "" : "\n{name:latin}") : "{name:latin}" + (noAlt ? "" : "\n{name:nonlatin}"),
|
||||
"filter-all-part": ["!has", "name:" + language],
|
||||
},
|
||||
{
|
||||
"layer-name-postfix": language,
|
||||
"layout.text-field":
|
||||
"{name:" + language + "}" + (noAlt ? "" : "\n{name:" + (isNonlatin ? "latin" : "nonlatin") + "}"),
|
||||
"layout.text-field": "{name:" + language + "}" + (noAlt ? "" : "\n{name:" + (isNonlatin ? "latin" : "nonlatin") + "}"),
|
||||
"filter-all-part": ["has", "name:" + language],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -89,10 +89,7 @@ export default class Session {
|
||||
}
|
||||
|
||||
// Restore authentication from session storage.
|
||||
if (
|
||||
this.applyAuthToken(this.storage.getItem(this.storageKey + ".token")) &&
|
||||
this.applyId(this.storage.getItem(this.storageKey + ".id"))
|
||||
) {
|
||||
if (this.applyAuthToken(this.storage.getItem(this.storageKey + ".token")) && this.applyId(this.storage.getItem(this.storageKey + ".id"))) {
|
||||
const dataJson = this.storage.getItem(this.storageKey + ".data");
|
||||
if (dataJson && dataJson !== "undefined") {
|
||||
this.data = JSON.parse(dataJson);
|
||||
|
||||
@@ -353,12 +353,7 @@ export default class $util {
|
||||
}
|
||||
|
||||
// Escape HTML control characters.
|
||||
text = text
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """)
|
||||
.replace(/'/g, "'");
|
||||
text = text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
||||
|
||||
// Make URLs clickable.
|
||||
text = text.replace(linkRegex, linkFunc);
|
||||
|
||||
@@ -521,10 +521,7 @@ export class View {
|
||||
const scope = this.scopes.map((s) => `${s?.$options?.name} #${s?.$?.uid.toString()}`).join(" › ");
|
||||
// To make them easy to recognize, the collapsed view logs are displayed
|
||||
// in the browser console with bold white text on a purple background.
|
||||
console.groupCollapsed(
|
||||
`%c${scope}`,
|
||||
"background: #502A85; color: white; padding: 3px 5px; border-radius: 8px; font-weight: bold;"
|
||||
);
|
||||
console.groupCollapsed(`%c${scope}`, "background: #502A85; color: white; padding: 3px 5px; border-radius: 8px; font-weight: bold;");
|
||||
console.log("data:", toRaw(c?.$data));
|
||||
}
|
||||
|
||||
@@ -744,11 +741,7 @@ export class View {
|
||||
|
||||
ev.preventDefault();
|
||||
|
||||
const target =
|
||||
(fallback && fallback.isConnected && root.contains(fallback) && fallback) ||
|
||||
resolveFocusTarget(root) ||
|
||||
findFocusElement(component) ||
|
||||
root;
|
||||
const target = (fallback && fallback.isConnected && root.contains(fallback) && fallback) || resolveFocusTarget(root) || findFocusElement(component) || root;
|
||||
|
||||
if (!target) {
|
||||
return;
|
||||
@@ -1019,10 +1012,7 @@ export class View {
|
||||
|
||||
const current = typeof this.navigation.currentPosition === "number" ? this.navigation.currentPosition : nextPos;
|
||||
|
||||
if (
|
||||
this.navigation.direction !== NavigationDirection.Back &&
|
||||
this.navigation.direction !== NavigationDirection.Forward
|
||||
) {
|
||||
if (this.navigation.direction !== NavigationDirection.Back && this.navigation.direction !== NavigationDirection.Forward) {
|
||||
if (nextPos < current) {
|
||||
this.navigation.direction = NavigationDirection.Back;
|
||||
} else if (nextPos > current) {
|
||||
|
||||
Reference in New Issue
Block a user