-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make T component update on changed id * Sort categories in create show before mapping them to Options This way sortObject uses the translatet names in default categories for sorting * Show chords with negative positions before the line in stageview * Forward all data in startImport to importShow Add encoding argument to readFile * 📑 Import Songbeamer files
- Loading branch information
Showing
15 changed files
with
970 additions
and
21 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
144 changes: 144 additions & 0 deletions
144
src/frontend/components/main/popups/SongbeamerImport.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<script lang="ts"> | ||
import T from "../../helpers/T.svelte" | ||
import CombinedInput from "../../inputs/CombinedInput.svelte" | ||
import Dropdown from "../../inputs/Dropdown.svelte" | ||
import Button from "../../inputs/Button.svelte" | ||
import Icon from "../../helpers/Icon.svelte" | ||
import { translate } from "../../../utils/language"; | ||
import { Option } from "../../../../types/Main" | ||
import { TranslationMethod } from "../../../../types/Songbeamer" | ||
import { sortObject } from "../../helpers/array" | ||
import { activePopup, categories } from "../../../stores" | ||
import { send } from "../../../utils/request" | ||
import { IMPORT } from "../../../../types/Channels" | ||
const encodingOptions = [ | ||
{ | ||
id: "utf8", | ||
name: translate("songbeamer_import.utf8"), | ||
}, | ||
{ | ||
id: "latin1", | ||
name: translate("songbeamer_import.latin1"), | ||
extra: translate("songbeamer_import.older_versions"), | ||
}, | ||
] | ||
let selectedEncoding: Option = encodingOptions[0] | ||
const songbeamerCatId: string = "songbeamer" | ||
let cats: any = [ | ||
...sortObject(Object.keys($categories).map((key: string) => ({ | ||
id: key, | ||
...$categories[key], | ||
})), "name").map((cat: any): Option => ({ | ||
id: cat.id, | ||
name: (cat.default? `$:${cat.name}:$` : cat.name), | ||
})), | ||
] | ||
let selectedCategory: Option = cats.find((el: Option) => el.id === songbeamerCatId) | ||
if(!selectedCategory) { | ||
selectedCategory = { | ||
id: songbeamerCatId, | ||
name: "Songbeamer", | ||
} | ||
cats.unshift(selectedCategory) | ||
} | ||
let selectedTranslationMethod = TranslationMethod.MultiLine | ||
function importListener() { | ||
send(IMPORT, ["songbeamer"], { | ||
encoding: selectedEncoding, | ||
category: selectedCategory, | ||
translation: selectedTranslationMethod, | ||
format: { | ||
extensions: ["sng"], | ||
}, | ||
}) | ||
$activePopup = null | ||
} | ||
</script> | ||
|
||
<h4><T id="songbeamer_import.options"/></h4> | ||
|
||
<CombinedInput textWidth={30}> | ||
<p><T id="songbeamer_import.encoding" /></p> | ||
<Dropdown value={selectedEncoding?.name} options={encodingOptions} on:click={evt => selectedEncoding = evt.detail}/> | ||
</CombinedInput> | ||
|
||
<CombinedInput textWidth={30}> | ||
<p><T id="show.category" /></p> | ||
<Dropdown options={cats} value={selectedCategory?.name} on:click={evt => selectedCategory = evt.detail} /> | ||
</CombinedInput> | ||
|
||
<h4><T id="songbeamer_import.translations" /></h4> | ||
|
||
<div class="translation-method"> | ||
{#each Object.values(TranslationMethod) as method} | ||
<Button | ||
center | ||
dark | ||
active={method === selectedTranslationMethod} | ||
on:click={() => selectedTranslationMethod = method} | ||
> | ||
<T id="songbeamer_import.translation_{method}" /> | ||
</Button> | ||
{/each} | ||
</div> | ||
|
||
<p class="translation-description"> | ||
<T id="songbeamer_import.translation_description_{selectedTranslationMethod}" /> | ||
</p> | ||
|
||
<hr /> | ||
|
||
<div class="import-button"> | ||
<Button center dark on:click={importListener}> | ||
<Icon id="import" size={1.2} right /> | ||
<T id="actions.import" /> | ||
</Button> | ||
</div> | ||
|
||
<style> | ||
h4 { | ||
color: var(--text); | ||
margin: 20px 0; | ||
text-align: center; | ||
} | ||
h4:first-child { | ||
margin-top: 0; | ||
} | ||
h4:last-child { | ||
margin-bottom: 0; | ||
} | ||
.translation-method { | ||
display: flex; | ||
flex-flow: wrap; | ||
} | ||
.translation-method :global(button) { | ||
flex: 1; | ||
border-bottom: 2px solid var(--primary-lighter); | ||
} | ||
.translation-method :global(button.active) { | ||
border-bottom: 2px solid var(--secondary) !important; | ||
} | ||
hr { | ||
border: none; | ||
height: 2px; | ||
margin: 20px 0; | ||
background-color: var(--primary-lighter); | ||
} | ||
.translation-description { | ||
margin: 10px 0; | ||
white-space: normal; | ||
} | ||
.import-button > :global(button) { | ||
width: 100%; | ||
} | ||
</style> |
Oops, something went wrong.