mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 10:30:28 +08:00
webconfig: Make prompt selectable
This commit is contained in:
parent
4b4cd4c45a
commit
209af84a37
|
@ -199,10 +199,12 @@
|
|||
<div class="prompt_demo_choice_label" style="color: #FFF;" x-text="selectedPrompt.name"></div>
|
||||
<div style='display: flex'>
|
||||
<div x-html='selectedPrompt.demo' style='flex-grow: 1' class="prompt_demo unbordered"></div>
|
||||
<div x-if='selectedPrompt.right' title="right prompt for {{selectedPrompt.name }}"
|
||||
x-html='selectedPrompt.right' class="prompt_demo unbordered"
|
||||
@click="selectPrompt(selectedPrompt)">
|
||||
</div>
|
||||
<template x-if="selectedPrompt.right">
|
||||
<div title="right prompt for {{selectedPrompt.name }}"
|
||||
x-html='selectedPrompt.right' class="prompt_demo unbordered"
|
||||
@click="selectPrompt(selectedPrompt)">
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div style="position: absolute; right: 5px; bottom: 5px;">
|
||||
<button class="save_button" x-show="showSaveButton" style="color: #CCC" @click="setPrompt()"
|
||||
|
|
|
@ -231,20 +231,24 @@ document.addEventListener("alpine:init", () => {
|
|||
this.savePromptButtonTitle = "Set Prompt";
|
||||
},
|
||||
|
||||
setNewPrompt(selectedPrompt) {
|
||||
$http
|
||||
.post("set_prompt/", { fish_prompt: selectedPrompt.function })
|
||||
.then(function (arg) {
|
||||
// Update attributes of current prompt and select it
|
||||
this.samplePrompts[0].demo = selectedPrompt.demo;
|
||||
this.samplePrompts[0].right = selectedPrompt.right;
|
||||
this.samplePrompts[0].function = selectedPrompt.function;
|
||||
this.samplePrompts[0].font_size = selectedPrompt.font_size;
|
||||
this.selectedPrompt = this.samplePrompts[0];
|
||||
async setNewPrompt(selectedPrompt) {
|
||||
let postdata = { fish_prompt: selectedPrompt.function };
|
||||
let resp = await fetch("set_prompt/", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(postdata)
|
||||
});
|
||||
if (resp.ok) {
|
||||
// Update attributes of current prompt and select it
|
||||
this.samplePrompts[0].demo = selectedPrompt.demo;
|
||||
this.samplePrompts[0].right = selectedPrompt.right;
|
||||
this.samplePrompts[0].function = selectedPrompt.function;
|
||||
this.samplePrompts[0].font_size = selectedPrompt.font_size;
|
||||
this.selectedPrompt = this.samplePrompts[0];
|
||||
|
||||
// Note that we set it
|
||||
this.savePromptButtonTitle = "Prompt Set!";
|
||||
});
|
||||
// Note that we set it
|
||||
this.savePromptButtonTitle = "Prompt Set!";
|
||||
};
|
||||
},
|
||||
|
||||
setPrompt() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user