Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Function to create the artifact item
- async function createArtifactItem(name, description, level, folderId) {
- let itemData = {
- name: name, // Use the name from the dialog
- type: "artifact", // Set the type to "cypher"
- system: {
- description: `<p>${description}</p>`, // Directly assign the description wrapped in <p> tags
- level: level
- },
- folder: folderId,
- };
- Item.create(itemData).then(item => {
- ui.notifications.info(`Created item: ${item.name}`);
- }).catch(err => {
- console.error(err);
- ui.notifications.error(`Could not create item: ${err.message}`);
- });
- }
- new Dialog({
- title: "New Artifact",
- content: `
- <form>
- <div class="form-group">
- <label>Artifact Name:</label>
- <input type="text" name="name" />
- </div>
- <div class="form-group">
- <label>Artifact Description:</label>
- <textarea name="description" rows="5"></textarea>
- </div>
- <div class="form-group">
- <label>Level:</label>
- <textarea name="level" rows="1"></textarea>
- </div>
- </form>
- `,
- buttons: {
- create: {
- label: "Create Artifact",
- callback: html => {
- let name = html.find("[name='name']").val();
- let description = html.find("[name='description']").val();
- let level = html.find("[name='level']").val();
- const folderId = 'Usrhaxw1OYfd0nUM'; // Use the folder id
- // Create the artifact item with the provided name, description, and level
- createArtifactItem(name, description, level, folderId);
- }
- },
- cancel: {
- label: "Cancel"
- }
- },
- default: "create"
- }).render(true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement