mirror of
https://github.com/turt2live/matrix-dimension.git
synced 2024-08-31 06:02:09 +00:00
Fix edit widget button
This commit is contained in:
parent
dd02c6df2c
commit
63a3b6b4c2
@ -1,4 +1,9 @@
|
||||
<my-ibox title="Add {{ defaultName }}">
|
||||
<div *ngIf="isLoading">
|
||||
<my-spinner></my-spinner>
|
||||
</div>
|
||||
|
||||
<div *ngIf="!isLoading">
|
||||
<my-ibox title="Add {{ defaultName }}" [isCollapsible]="true" [defaultCollapsed]="defaultExpandedWidgetId">
|
||||
<div class="my-ibox-content">
|
||||
<form (submit)="addWidget()" novalidate name="addForm">
|
||||
<label class="label-block">
|
||||
@ -21,9 +26,9 @@
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</my-ibox>
|
||||
</my-ibox>
|
||||
|
||||
<my-ibox *ngFor="let widget of widgets trackById"
|
||||
<my-ibox *ngFor="let widget of widgets trackById"
|
||||
[isCollapsible]="true" [defaultCollapsed]="widget.id !== defaultExpandedWidgetId"
|
||||
title="{{ widget.name || widget.url || defaultName }}">
|
||||
<div class="my-ibox-content">
|
||||
@ -51,8 +56,9 @@
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-white" [disabled]="isUpdating" (click)="resetWidget(widget)"
|
||||
*ngIf="hasChanges(widget)">
|
||||
<i class="fa fa-reset"></i> Undo Changes
|
||||
<i class="fa fa-undo"></i> Undo Changes
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</my-ibox>
|
||||
</my-ibox>
|
||||
</div>
|
@ -71,11 +71,12 @@ export class NewWidgetComponent {
|
||||
}
|
||||
|
||||
// See if we should request editing a particular widget
|
||||
if (SessionStorage.editWidgetId && SessionStorage.editsRequested === 1) {
|
||||
console.log(SessionStorage.editIntegrationId +" " +SessionStorage.editsRequested);
|
||||
if (SessionStorage.editIntegrationId && SessionStorage.editsRequested === 1) {
|
||||
let editWidget: EditableWidget = null;
|
||||
let otherWidgets: EditableWidget[] = [];
|
||||
for (let widget of this.widgets) {
|
||||
if (widget.id === SessionStorage.editWidgetId) {
|
||||
if (widget.id === SessionStorage.editIntegrationId) {
|
||||
editWidget = widget;
|
||||
} else otherWidgets.push(widget);
|
||||
}
|
||||
@ -318,7 +319,7 @@ export class NewWidgetComponent {
|
||||
* @param {EditableWidget} widget The widget to check
|
||||
* @returns {boolean} True if the widget has been edited
|
||||
*/
|
||||
public hasChanges(widget: EditableWidget):boolean {
|
||||
public hasChanges(widget: EditableWidget): boolean {
|
||||
if (widget.dimension.newUrl !== this.unwrapUrl(widget.url)) return true;
|
||||
if (widget.dimension.newName !== widget.name) return true;
|
||||
if (widget.dimension.newTitle !== widget.data.title) return true;
|
||||
|
@ -29,7 +29,7 @@ export class RiotHomeComponent {
|
||||
private roomId: string;
|
||||
private userId: string;
|
||||
private requestedScreen: string = null;
|
||||
private requestedIntegration: string = null;
|
||||
private requestedIntegrationId: string = null;
|
||||
public integrationsForCategory: { [category: string]: Integration[] } = {};
|
||||
private categoryMap: { [categoryName: string]: string[] } = CATEGORY_MAP;
|
||||
|
||||
@ -42,7 +42,7 @@ export class RiotHomeComponent {
|
||||
let params: any = this.activatedRoute.snapshot.queryParams;
|
||||
|
||||
this.requestedScreen = params.screen;
|
||||
this.requestedIntegration = params.integ_id;
|
||||
this.requestedIntegrationId = params.integ_id;
|
||||
|
||||
if (SessionStorage.roomId && SessionStorage.userId) {
|
||||
this.roomId = SessionStorage.roomId;
|
||||
@ -208,8 +208,9 @@ export class RiotHomeComponent {
|
||||
console.log("Searching for integration for requested screen");
|
||||
for (const integration of this.getIntegrations()) {
|
||||
if (integration.category === category && integration.type === type) {
|
||||
console.log("Configuring integration " + this.requestedIntegration + " category=" + category + " type=" + type);
|
||||
console.log("Configuring integration " + this.requestedIntegrationId + " category=" + category + " type=" + type);
|
||||
SessionStorage.editIntegration = integration;
|
||||
SessionStorage.editIntegrationId = this.requestedIntegrationId;
|
||||
this.modifyIntegration(integration);
|
||||
return;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ export class SessionStorage {
|
||||
public static userId: string;
|
||||
public static roomId: string;
|
||||
public static editIntegration: Integration;
|
||||
public static editWidgetId: string;
|
||||
public static editIntegrationId: string;
|
||||
public static editsRequested: number = 0;
|
||||
|
||||
private constructor() {
|
||||
|
@ -53,11 +53,13 @@ export class IntegrationService {
|
||||
}
|
||||
|
||||
static getIntegrationForScreen(screen: string): { category: string, type: string } {
|
||||
for (const iType of Object.keys(IntegrationService.supportedIntegrationsMap)) {
|
||||
for (const iiType of Object.keys(IntegrationService.supportedIntegrationsMap[iType])) {
|
||||
const integrationTypes = IntegrationService.supportedIntegrationsMap[iType][iiType].types;
|
||||
for (const category of Object.keys(IntegrationService.supportedIntegrationsMap)) {
|
||||
for (const type of Object.keys(IntegrationService.supportedIntegrationsMap[category])) {
|
||||
const integrationTypes = IntegrationService.supportedIntegrationsMap[category][type].types;
|
||||
if (!integrationTypes) continue;
|
||||
|
||||
const integrationScreens = integrationTypes.map(t => "type_" + t);
|
||||
if (integrationScreens.includes(screen)) return {category: iType, type: iiType};
|
||||
if (integrationScreens.includes(screen)) return {category: category, type: type};
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user