mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
Instead of always using the first alias. "Tag input" fields (edit page, bulk tagging, etc.) will display the matched name in suggestions, and use the first alias upon selection.
85 lines
2.2 KiB
JavaScript
85 lines
2.2 KiB
JavaScript
"use strict";
|
|
|
|
const events = require("../events.js");
|
|
const api = require("../api.js");
|
|
const views = require("../util/views.js");
|
|
const PoolAutoCompleteControl = require("../controls/pool_auto_complete_control.js");
|
|
|
|
const template = views.getTemplate("pool-merge");
|
|
|
|
class PoolMergeView extends events.EventTarget {
|
|
constructor(ctx) {
|
|
super();
|
|
|
|
this._pool = ctx.pool;
|
|
this._hostNode = ctx.hostNode;
|
|
this._targetPoolId = null;
|
|
ctx.poolNamePattern = api.getPoolNameRegex();
|
|
views.replaceContent(this._hostNode, template(ctx));
|
|
|
|
views.decorateValidator(this._formNode);
|
|
if (this._targetPoolFieldNode) {
|
|
this._autoCompleteControl = new PoolAutoCompleteControl(
|
|
this._targetPoolFieldNode,
|
|
{
|
|
confirm: (pool) => {
|
|
this._targetPoolId = pool.id;
|
|
this._autoCompleteControl.replaceSelectedText(
|
|
pool.matchingNames[0],
|
|
false
|
|
);
|
|
},
|
|
}
|
|
);
|
|
}
|
|
|
|
this._formNode.addEventListener("submit", (e) => this._evtSubmit(e));
|
|
}
|
|
|
|
clearMessages() {
|
|
views.clearMessages(this._hostNode);
|
|
}
|
|
|
|
enableForm() {
|
|
views.enableForm(this._formNode);
|
|
}
|
|
|
|
disableForm() {
|
|
views.disableForm(this._formNode);
|
|
}
|
|
|
|
showSuccess(message) {
|
|
views.showSuccess(this._hostNode, message);
|
|
}
|
|
|
|
showError(message) {
|
|
views.showError(this._hostNode, message);
|
|
}
|
|
|
|
_evtSubmit(e) {
|
|
e.preventDefault();
|
|
this.dispatchEvent(
|
|
new CustomEvent("submit", {
|
|
detail: {
|
|
pool: this._pool,
|
|
targetPoolId: this._targetPoolId,
|
|
},
|
|
})
|
|
);
|
|
}
|
|
|
|
get _formNode() {
|
|
return this._hostNode.querySelector("form");
|
|
}
|
|
|
|
get _targetPoolFieldNode() {
|
|
return this._formNode.querySelector("input[name=target-pool]");
|
|
}
|
|
|
|
get _addAliasCheckboxNode() {
|
|
return this._formNode.querySelector("input[name=alias]");
|
|
}
|
|
}
|
|
|
|
module.exports = PoolMergeView;
|