2023-10-03 19:20:57 +00:00
|
|
|
// import {AccessLevel} from "app/common/CustomWidget";
|
|
|
|
// import {ViewSectionRec} from "app/client/models/entities/ViewSectionRec";
|
|
|
|
import { CustomView, CustomViewSettings } from "app/client/components/CustomView";
|
|
|
|
import { AccessLevel } from "app/common/CustomWidget";
|
|
|
|
// import {GristDoc} from "app/client/components/GristDoc";
|
|
|
|
// import {reportError} from 'app/client/models/errors';
|
2023-08-29 14:50:42 +00:00
|
|
|
|
|
|
|
//Abstract class for more future inheritances
|
2023-10-03 19:20:57 +00:00
|
|
|
// abstract class CustomAttachedView extends CustomView {
|
|
|
|
/*
|
2023-08-29 14:50:42 +00:00
|
|
|
public override create(gristDoc: GristDoc, viewSectionModel: ViewSectionRec) {
|
|
|
|
super.create(gristDoc, viewSectionModel);
|
2023-09-27 21:00:33 +00:00
|
|
|
if (viewSectionModel.customDef.access.peek() !== AccessLevel.full) {
|
|
|
|
void viewSectionModel.customDef.access.setAndSave(AccessLevel.full).catch((err)=>{
|
|
|
|
if (err?.code === "ACL_DENY") {
|
|
|
|
// do nothing, we might be in a readonly mode.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
reportError(err);
|
|
|
|
});
|
|
|
|
}
|
2023-08-29 14:50:42 +00:00
|
|
|
|
2023-10-03 19:20:57 +00:00
|
|
|
const widgetsApi = this.gristDoc.app.topAppModel;
|
2023-08-29 14:50:42 +00:00
|
|
|
widgetsApi.getWidgets().then(async result=>{
|
|
|
|
const widget = result.find(w=>w.name == this.getWidgetName());
|
2023-09-27 21:00:33 +00:00
|
|
|
if (widget && this.customDef.url.peek() !== widget.url) {
|
2023-08-29 14:50:42 +00:00
|
|
|
await this.customDef.url.setAndSave(widget.url);
|
|
|
|
}
|
2023-09-27 21:00:33 +00:00
|
|
|
}).catch((err)=>{
|
|
|
|
if (err?.code !== "ACL_DENY") {
|
|
|
|
// TODO: revisit it later. getWidgets() is async call, and non of the code
|
|
|
|
// above is checking if we are still alive.
|
|
|
|
console.error(err);
|
|
|
|
} else {
|
|
|
|
// do nothing, we might be in a readonly mode.
|
|
|
|
}
|
2023-08-29 14:50:42 +00:00
|
|
|
});
|
|
|
|
}
|
2023-10-03 19:20:57 +00:00
|
|
|
*/
|
2023-08-29 14:50:42 +00:00
|
|
|
|
2023-10-03 19:20:57 +00:00
|
|
|
// protected abstract getWidgetName(): string;
|
2023-08-29 14:50:42 +00:00
|
|
|
|
2023-10-03 19:20:57 +00:00
|
|
|
// }
|
2023-08-29 14:50:42 +00:00
|
|
|
|
2023-10-03 19:20:57 +00:00
|
|
|
export class CustomCalendarView extends CustomView {
|
|
|
|
protected getInitialSettings(): CustomViewSettings {
|
|
|
|
return {
|
|
|
|
widgetId: '@gristlabs/widget-calendar',
|
|
|
|
accessLevel: AccessLevel.full,
|
|
|
|
};
|
2023-08-29 14:50:42 +00:00
|
|
|
}
|
|
|
|
}
|