mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-24 17:04:14 +01:00
Fix editable tags failed their tests
editable was not passed to tag, edit mode broke
This commit is contained in:
parent
39d2b0aa54
commit
d1bfe30c79
@ -6,6 +6,7 @@ import {ManualMessage} from "../Validators/ManualMessage";
|
|||||||
import {LionValidationFeedback, Validator} from "@lion/form-core";
|
import {LionValidationFeedback, Validator} from "@lion/form-core";
|
||||||
import {et2_csvSplit} from "../et2_core_common";
|
import {et2_csvSplit} from "../et2_core_common";
|
||||||
import {dedupeMixin} from "@lion/core";
|
import {dedupeMixin} from "@lion/core";
|
||||||
|
import {property} from "lit/decorators/property.js";
|
||||||
|
|
||||||
// LionValidationFeedback needs to be registered manually
|
// LionValidationFeedback needs to be registered manually
|
||||||
window.customElements.define('lion-validation-feedback', LionValidationFeedback);
|
window.customElements.define('lion-validation-feedback', LionValidationFeedback);
|
||||||
@ -53,6 +54,7 @@ const Et2InputWidgetMixin = <T extends Constructor<LitElement>>(superclass : T)
|
|||||||
class Et2InputWidgetClass extends Et2Widget(superclass) implements et2_IInput, et2_IInputNode, et2_ISubmitListener
|
class Et2InputWidgetClass extends Et2Widget(superclass) implements et2_IInput, et2_IInputNode, et2_ISubmitListener
|
||||||
{
|
{
|
||||||
private __readonly : boolean;
|
private __readonly : boolean;
|
||||||
|
private __label : string = "";
|
||||||
protected _oldValue : string | number | Object;
|
protected _oldValue : string | number | Object;
|
||||||
protected node : HTMLElement;
|
protected node : HTMLElement;
|
||||||
|
|
||||||
@ -186,7 +188,7 @@ const Et2InputWidgetMixin = <T extends Constructor<LitElement>>(superclass : T)
|
|||||||
this.defaultValidators = [];
|
this.defaultValidators = [];
|
||||||
this._messagesHeldWhileFocused = [];
|
this._messagesHeldWhileFocused = [];
|
||||||
|
|
||||||
this.__readonly = false;
|
this.readonly = false;
|
||||||
this._oldValue = this.getValue();
|
this._oldValue = this.getValue();
|
||||||
|
|
||||||
this.isSlComponent = typeof (<any>this).handleChange === 'function';
|
this.isSlComponent = typeof (<any>this).handleChange === 'function';
|
||||||
@ -390,12 +392,14 @@ const Et2InputWidgetMixin = <T extends Constructor<LitElement>>(superclass : T)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The label of the widget
|
||||||
* Legacy support for labels with %s that get wrapped around the widget
|
* Legacy support for labels with %s that get wrapped around the widget
|
||||||
*
|
*
|
||||||
* Not the best way go with webComponents - shouldn't modify their DOM like this
|
* Not the best way go with webComponents - shouldn't modify their DOM like this
|
||||||
*
|
*
|
||||||
* @param new_label
|
* @param new_label
|
||||||
*/
|
*/
|
||||||
|
@property()
|
||||||
set label(new_label : string)
|
set label(new_label : string)
|
||||||
{
|
{
|
||||||
if(!new_label || !new_label.includes("%s"))
|
if(!new_label || !new_label.includes("%s"))
|
||||||
|
@ -967,7 +967,7 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
|
|||||||
size=${this.size || "medium"}
|
size=${this.size || "medium"}
|
||||||
?removable=${!readonly}
|
?removable=${!readonly}
|
||||||
?readonly=${readonly}
|
?readonly=${readonly}
|
||||||
?editable=${isEditable}
|
.editable=${isEditable}
|
||||||
.value=${option.value.replaceAll("___", " ")}
|
.value=${option.value.replaceAll("___", " ")}
|
||||||
@change=${this.handleTagEdit}
|
@change=${this.handleTagEdit}
|
||||||
@dblclick=${this._handleDoubleClick}
|
@dblclick=${this._handleDoubleClick}
|
||||||
|
@ -12,6 +12,8 @@ import {css, html, TemplateResult} from "lit";
|
|||||||
import {classMap} from "lit/directives/class-map.js";
|
import {classMap} from "lit/directives/class-map.js";
|
||||||
import shoelace from "../../Styles/shoelace";
|
import shoelace from "../../Styles/shoelace";
|
||||||
import {state} from "lit/decorators/state.js";
|
import {state} from "lit/decorators/state.js";
|
||||||
|
import {property} from "lit/decorators/property.js";
|
||||||
|
import {Et2Textbox} from "../../Et2Textbox/Et2Textbox";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tag is usually used in a Select with multiple=true, but there's no reason it can't go anywhere
|
* Tag is usually used in a Select with multiple=true, but there's no reason it can't go anywhere
|
||||||
@ -69,23 +71,16 @@ export class Et2Tag extends Et2Widget(SlTag)
|
|||||||
`];
|
`];
|
||||||
}
|
}
|
||||||
|
|
||||||
static get properties()
|
@property({type: Boolean}) editable = false;
|
||||||
{
|
@property({type: String, reflect: true}) value = "";
|
||||||
return {
|
|
||||||
...super.properties,
|
|
||||||
editable: {type: Boolean, reflect: true},
|
|
||||||
value: {type: String, reflect: true}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@state() current = false; // the user has keyed into the tag (focused), but hasn't done anything yet (shows a highlight)
|
@state() current = false; // the user has keyed into the tag (focused), but hasn't done anything yet (shows a highlight)
|
||||||
|
@state() isEditing = false;
|
||||||
|
|
||||||
constructor(...args : [])
|
constructor(...args : [])
|
||||||
{
|
{
|
||||||
super(...args);
|
super(...args);
|
||||||
this.value = "";
|
|
||||||
this.pill = false;
|
this.pill = false;
|
||||||
this.editable = false;
|
|
||||||
this.removable = true;
|
this.removable = true;
|
||||||
|
|
||||||
this.handleKeyDown = this.handleKeyDown.bind(this);
|
this.handleKeyDown = this.handleKeyDown.bind(this);
|
||||||
@ -203,8 +198,9 @@ export class Et2Tag extends Et2Widget(SlTag)
|
|||||||
this.setAttribute("contenteditable", "true");
|
this.setAttribute("contenteditable", "true");
|
||||||
|
|
||||||
this.requestUpdate();
|
this.requestUpdate();
|
||||||
this.updateComplete.then(() =>
|
this.updateComplete.then(async() =>
|
||||||
{
|
{
|
||||||
|
await this._editNode.updateComplete;
|
||||||
// This stops drag and drop from interfereing with mouse edits
|
// This stops drag and drop from interfereing with mouse edits
|
||||||
this._editNode.input.setAttribute("contenteditable", "true");
|
this._editNode.input.setAttribute("contenteditable", "true");
|
||||||
|
|
||||||
@ -233,7 +229,7 @@ export class Et2Tag extends Et2Widget(SlTag)
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
get _editNode() : HTMLInputElement
|
get _editNode() : Et2Textbox
|
||||||
{
|
{
|
||||||
return this.shadowRoot.querySelector('et2-textbox');
|
return this.shadowRoot.querySelector('et2-textbox');
|
||||||
}
|
}
|
||||||
|
@ -149,6 +149,7 @@ describe("Select is not editable", () =>
|
|||||||
|
|
||||||
it("Does not have edit button when not editable", async() =>
|
it("Does not have edit button when not editable", async() =>
|
||||||
{
|
{
|
||||||
|
debugger;
|
||||||
let tag = element.select.combobox.querySelectorAll(tag_name);
|
let tag = element.select.combobox.querySelectorAll(tag_name);
|
||||||
assert.isAbove(tag.length, 0, "No tags found");
|
assert.isAbove(tag.length, 0, "No tags found");
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
"rootDir": "./",
|
"rootDir": "./",
|
||||||
"emitDecoratorMetadata": false,
|
"emitDecoratorMetadata": false,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
"removeComments": false,
|
"removeComments": false,
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
|
Loading…
Reference in New Issue
Block a user