Skip to content

Commit

Permalink
feat: move export button to forms view
Browse files Browse the repository at this point in the history
  • Loading branch information
theotheo committed Oct 21, 2023
1 parent ca20241 commit b185e4c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
12 changes: 1 addition & 11 deletions src/views/FormBuilder.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
validateFields,
} from "src/core/formDefinition";
import { FolderSuggest } from "src/suggesters/suggestFolder";
import { setIcon, Setting, App, Notice } from "obsidian";
import { setIcon, Setting, App } from "obsidian";
import FormRow from "./components/FormRow.svelte";
import InputBuilderDataview from "./components/inputBuilderDataview.svelte";
import InputBuilderSelect from "./components/InputBuilderSelect.svelte";
Expand Down Expand Up @@ -90,11 +90,6 @@
if (!isValidFormDefinition(definition)) return;
onPreview(definition);
};
const handleExport = () => {
if (!isValidFormDefinition(definition)) return;
navigator.clipboard.writeText(JSON.stringify(definition));
new Notice("Form has been copied to the clipboard");
};
</script>

<div class="flex column gap2 wrapper modal-form">
Expand Down Expand Up @@ -149,11 +144,6 @@
<button type="button" class="mod-warning" on:click={onCancel}
>Cancel</button
>
<button
type="button"
use:setIcon={"clipboard-copy"}
on:click={handleExport}
disabled={!isValid}/>
</div>
{#if errors.length > 0}
<h3 style="margin: 0;">
Expand Down
9 changes: 8 additions & 1 deletion src/views/ManageFormsView.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ModalFormPlugin from "../main";
import { ItemView, Setting, WorkspaceLeaf } from "obsidian";
import { ItemView, Notice, Setting, WorkspaceLeaf } from "obsidian";

export const MANAGE_FORMS_VIEW = "modal-form-manage-forms-view";

Expand Down Expand Up @@ -78,6 +78,13 @@ export class ManageFormsView extends ItemView {
this.plugin.duplicateForm(form);
})
})
.addButton(button => {
button.setIcon('clipboard-copy')
button.onClick(() => {
navigator.clipboard.writeText(JSON.stringify(form, null, 2));
new Notice("Form has been copied to the clipboard");
});
})
;
})
}
Expand Down

0 comments on commit b185e4c

Please sign in to comment.