implement flow refinements as discussed with Nad,add text client support

This commit is contained in:
Bruno Windels
2020-12-01 19:01:15 +01:00
parent cf489284c9
commit 1caa9b1bf3
8 changed files with 130 additions and 86 deletions
+6 -10
View File
@@ -21,23 +21,19 @@ import {ClientView} from "../client/ClientView.js";
export class PreviewView extends TemplateView {
render(t, vm) {
return t.div({className: "PreviewView card"}, [
t.h2({className: {hidden: vm => !vm.loading}}, "Loading preview…"),
t.h1({className: {hidden: vm => !vm.loading}}, "Loading preview…"),
t.div({className: {hidden: vm => vm.loading}}, [
t.div({className: "preview"}, [
t.p(t.img({className: "avatar", src: vm => vm.avatarUrl})),
t.div({className: "profileInfo"}, [
t.h2(vm => vm.name),
t.p(vm => vm.identifier),
t.p(["Preview from ", vm => vm.previewDomain]),
]),
t.h1(vm => vm.name),
t.p(vm => vm.identifier),
]),
t.p({className: {hidden: vm => !vm.canShowClients}}, t.button({
className: "primary",
t.p({className: {hidden: vm => vm.clientsViewModel}}, t.button({
className: "primary fullwidth",
onClick: () => vm.showClients()
}, vm => vm.showClientsLabel)),
t.mapView(vm => vm.clientsViewModel, childVM => childVM ? new ClientListView(childVM) : null),
t.mapView(vm => vm.preferredClientViewModel, childVM => childVM ? new ClientView(childVM) : null),
t.p({className: {hidden: vm => !vm.preferredClientViewModel}}, vm => `This will open in ${vm.preferredClientViewModel?.name}`),
t.p(["Preview provided by ", vm => vm.previewDomain]),
])
]);
}
+4 -7
View File
@@ -35,9 +35,10 @@ export class PreviewViewModel extends ViewModel {
this.previewDomain = null;
this.clientsViewModel = null;
this.acceptInstructions = null;
this.preferredClientViewModel = this._preferredClient ? new ClientViewModel(this.childOptions({
this.clientsViewModel = this._preferredClient ? new ClientListViewModel(this.childOptions({
clients: this._clients,
client: this._preferredClient,
link: this._link
link: this._link,
})) : null;
}
@@ -74,16 +75,12 @@ export class PreviewViewModel extends ViewModel {
return this._link.identifier;
}
get canShowClients() {
return !(this.preferredClientViewModel || this.clientsViewModel);
}
get showClientsLabel() {
return getLabelForLinkKind(this._link.kind);
}
showClients() {
if (!this._preferredClient) {
if (!this.clientsViewModel) {
this.clientsViewModel = new ClientListViewModel(this.childOptions({clients: this._clients, link: this._link}));
this.emitChange();
}