@intuitionrobotics/live-docs
Version:
57 lines • 2.76 kB
JavaScript
;
/*
* Permissions management system, define access level for each of
* your server apis, and restrict users by giving them access levels
*
* Copyright (C) 2020 Intuition Robotics
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.showEditModalExample = exports.setDefaultLiveDocEditor = void 0;
const React = require("react");
const frontend_1 = require("@intuitionrobotics/thunderstorm/frontend");
const LiveDocsModule_1 = require("./modules/LiveDocsModule");
const resolver = (docKey) => {
const doc = LiveDocsModule_1.LiveDocsModule.get(docKey);
return new frontend_1.ToastBuilder().setContent(doc.document.length === 0 ? `No Content for document with key: ${docKey}` : doc.document).setActions([React.createElement("button", { style: { marginRight: 8 }, onClick: () => exports.showEditModalExample(docKey) }, "Edit")]);
};
function setDefaultLiveDocEditor() {
LiveDocsModule_1.LiveDocsModule.setActionsResolver(resolver);
}
exports.setDefaultLiveDocEditor = setDefaultLiveDocEditor;
const showEditModalExample = (docKey) => {
const title = "Default Edit modal";
const doc = LiveDocsModule_1.LiveDocsModule.get(docKey);
const originalDoc = doc.document;
const content = React.createElement(frontend_1.TS_TextArea, { type: "text", style: { height: "110px", margin: "8px", width: "100%", outline: "none" }, value: doc.document, onChange: (value) => {
doc.document = value;
frontend_1.ToastModule.toastInfo(doc.document);
} });
new frontend_1.Dialog_Builder(content)
.setTitle(title)
.setStyle({ maxWidth: "400px", width: "350px", height: "220px" })
.addButton(frontend_1.DialogButton_Cancel(() => {
doc.document = originalDoc;
frontend_1.DialogModule.close();
}))
.addButton(frontend_1.DialogButton_Save(() => {
const liveDoc = { key: docKey, document: doc.document };
LiveDocsModule_1.LiveDocsModule.update(liveDoc);
frontend_1.DialogModule.close();
}))
.setOverlayColor("rgba(102, 255, 255, 0.4)")
.show();
};
exports.showEditModalExample = showEditModalExample;
//# sourceMappingURL=utils.js.map