allow to create more links
This commit is contained in:
parent
7bb2ba91c3
commit
19ce0c8b69
@ -54,12 +54,14 @@ export class CreateLinkView extends TemplateView {
|
|||||||
t.div({className: {hidden: vm => !vm.linkUrl}}, [
|
t.div({className: {hidden: vm => !vm.linkUrl}}, [
|
||||||
t.h2(link),
|
t.h2(link),
|
||||||
t.div(copyButton(t, link, "Copy link", "fullwidth primary")),
|
t.div(copyButton(t, link, "Copy link", "fullwidth primary")),
|
||||||
|
t.div(t.button({className: "secondary fullwidth", onClick: () => this._clear()}, "Or create another link")),
|
||||||
]),
|
]),
|
||||||
t.form({action: "#", onSubmit: evt => this._onSubmit(evt), className: {hidden: vm => vm.linkUrl}}, [
|
t.form({action: "#", onSubmit: evt => this._onSubmit(evt), className: {hidden: vm => vm.linkUrl}}, [
|
||||||
t.div(t.input({
|
t.div(t.input({
|
||||||
className: "fullwidth large",
|
className: "fullwidth large",
|
||||||
type: "text",
|
type: "text",
|
||||||
name: "identifier",
|
name: "identifier",
|
||||||
|
required: true,
|
||||||
placeholder: "#room:example.com, @user:example.com",
|
placeholder: "#room:example.com, @user:example.com",
|
||||||
onChange: evt => this._onIdentifierChange(evt)
|
onChange: evt => this._onIdentifierChange(evt)
|
||||||
})),
|
})),
|
||||||
@ -71,8 +73,10 @@ export class CreateLinkView extends TemplateView {
|
|||||||
_onSubmit(evt) {
|
_onSubmit(evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
const form = evt.target;
|
const form = evt.target;
|
||||||
const identifier = form.elements.identifier.value;
|
const {identifier} = form.elements;
|
||||||
this.value.createLink(identifier);
|
this.value.createLink(identifier.value);
|
||||||
|
identifier.value = "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_onIdentifierChange(evt) {
|
_onIdentifierChange(evt) {
|
||||||
@ -83,4 +87,10 @@ export class CreateLinkView extends TemplateView {
|
|||||||
inputField.setCustomValidity("");
|
inputField.setCustomValidity("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_clear() {
|
||||||
|
this.value.clear();
|
||||||
|
const textField = this.root().querySelector("input[name=identifier]");
|
||||||
|
textField.focus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import {Link} from "../Link.js";
|
|||||||
export class CreateLinkViewModel extends ViewModel {
|
export class CreateLinkViewModel extends ViewModel {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
super(options);
|
super(options);
|
||||||
|
this._link = null;
|
||||||
this.previewViewModel = null;
|
this.previewViewModel = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,4 +50,10 @@ export class CreateLinkViewModel extends ViewModel {
|
|||||||
return `${this.origin}/#${this._link.toFragment()}`;
|
return `${this.origin}/#${this._link.toFragment()}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clear() {
|
||||||
|
this._link = null;
|
||||||
|
this.previewViewModel = null;
|
||||||
|
this.emitChange();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user