Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: whiteout issue #2

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ <h2 class="text-red" v-if="displayDupError">Oh sorry, you can't have duplicated

<b-field horizontal label="Language">
<v-select style="width: 186px" label="name" :options="sortedLanguagesByUse" placeholder="Select a language"
v-model="file.language" :reduce="selectedLanguage => selectedLanguage.name">
v-model="file.language" :reduce="selectedLanguage => selectedLanguage.name" :clearable="false">
<template v-slot:option="option">
{{ option.name | capitalize }}
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,27 +111,18 @@ export default {
computed: {
...mapGetters(['gistsSelected', 'notes']),
isDisabled() {
let isCreateButtonDisabled = false;
const isGistDisabled = () => (
!/\S/.test(this.note.description) ||
this.files.some(file => !/\S/.test(file.name)) ||
this.files.some(file => !/\S/.test(file.language)) ||
this.files.some(file => !/\S/.test(file.content))
);

if(this.getNoteType() === "gist"){
if(this.files.some(file => !/\S/.test(file.content)) ||
this.files.some(file => !/\S/.test(file.name)) ||
this.files.some(file => !/\S/.test(this.note.description))){
isCreateButtonDisabled = true;
} else {
isCreateButtonDisabled = false;
}
} if(this.getNoteType() === "note"){
if(this.files.some(file => !/\S/.test(file.content)) ||
this.files.some(file => !/\S/.test(file.name)) ||
this.files.some(file => !/\S/.test(this.note.name)) ||
this.files.some(file => !/\S/.test(this.note.description))){
isCreateButtonDisabled = true;
} else {
isCreateButtonDisabled = false;
}
}
return isCreateButtonDisabled;
const isNoteDisabled = () => (
isGistDisabled() || !/\S/.test(this.note.name)
);

return this.gistsSelected ? isGistDisabled() : isNoteDisabled();
},
sortedLanguagesByUse() {
this.languages.forEach((language) => { language.frequency = 0; });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ <h2 class="text-red" v-if="displayDupError">Oh sorry, you can't have duplicated
</b-field>

<b-field horizontal label="Language">
<b-select placeholder="Select a language" v-model="file.language">
<b-select placeholder="Select a language" v-model="file.language" :clearable="false">
<option
v-for="language in languages"
:value="language.name">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,27 +135,18 @@ export default {
computed: {
...mapGetters(['gistsSelected']),
isDisabled() {
let isCreateButtonDisabled = false;
const isGistDisabled = () => (
!/\S/.test(this.noteUpdated.description) ||
this.files.some(file => !/\S/.test(file.name)) ||
this.files.some(file => !/\S/.test(file.language)) ||
this.files.some(file => !/\S/.test(file.content))
);

if(this.getNoteType() === "gist"){
if(this.files.some(file => !/\S/.test(file.content)) ||
this.files.some(file => !/\S/.test(file.name)) ||
this.files.some(file => !/\S/.test(this.noteUpdated.description))){
isCreateButtonDisabled = true;
} else {
isCreateButtonDisabled = false;
}
} if(this.getNoteType() === "note"){
if(this.files.some(file => !/\S/.test(file.content)) ||
this.files.some(file => !/\S/.test(file.name)) ||
this.files.some(file => !/\S/.test(this.noteUpdated.name)) ||
this.files.some(file => !/\S/.test(this.noteUpdated.description))){
isCreateButtonDisabled = true;
} else {
isCreateButtonDisabled = false;
}
}
return isCreateButtonDisabled;
const isNoteDisabled = () => (
isGistDisabled() || !/\S/.test(this.noteUpdated.name)
);

return this.gistsSelected ? isGistDisabled() : isNoteDisabled();
},
},
};
Expand Down