aboutsummaryrefslogtreecommitdiff
path: root/src/components/settings_modal/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/settings_modal/helpers')
-rw-r--r--src/components/settings_modal/helpers/attachment_setting.vue2
-rw-r--r--src/components/settings_modal/helpers/emoji_editing_popover.vue97
-rw-r--r--src/components/settings_modal/helpers/number_setting.vue3
-rw-r--r--src/components/settings_modal/helpers/setting.js10
-rw-r--r--src/components/settings_modal/helpers/size_setting.js40
-rw-r--r--src/components/settings_modal/helpers/string_setting.vue2
-rw-r--r--src/components/settings_modal/helpers/unit_setting.js64
-rw-r--r--src/components/settings_modal/helpers/unit_setting.vue (renamed from src/components/settings_modal/helpers/size_setting.vue)24
8 files changed, 147 insertions, 95 deletions
diff --git a/src/components/settings_modal/helpers/attachment_setting.vue b/src/components/settings_modal/helpers/attachment_setting.vue
index b50231f2..96c80ab1 100644
--- a/src/components/settings_modal/helpers/attachment_setting.vue
+++ b/src/components/settings_modal/helpers/attachment_setting.vue
@@ -29,7 +29,7 @@
<label for="path">{{ $t('settings.url') }}</label>
<input
:id="path"
- class="string-input"
+ class="input string-input"
:disabled="shouldBeDisabled"
:value="realDraftMode ? draft : state"
@change="update"
diff --git a/src/components/settings_modal/helpers/emoji_editing_popover.vue b/src/components/settings_modal/helpers/emoji_editing_popover.vue
index cdd3e403..f0465dd5 100644
--- a/src/components/settings_modal/helpers/emoji_editing_popover.vue
+++ b/src/components/settings_modal/helpers/emoji_editing_popover.vue
@@ -1,10 +1,10 @@
<template>
<Popover
+ ref="emojiPopover"
trigger="click"
:placement="placement"
bound-to-selector=".emoji-list"
popover-class="emoji-tab-edit-popover popover-default"
- ref="emojiPopover"
:bound-to="{ x: 'container' }"
:offset="{ y: 5 }"
:disabled="disabled"
@@ -18,23 +18,36 @@
{{ title }}
</h3>
- <StillImage class="emoji" v-if="emojiPreview" :src="emojiPreview" />
- <div v-else class="emoji"></div>
-
- <div class="emoji-tab-popover-input" v-if="newUpload">
+ <StillImage
+ v-if="emojiPreview"
+ class="emoji"
+ :src="emojiPreview"
+ />
+ <div
+ v-else
+ class="emoji"
+ />
+
+ <div
+ v-if="newUpload"
+ class="emoji-tab-popover-input"
+ >
<input
type="file"
accept="image/*"
- class="emoji-tab-popover-file"
- @change="uploadFile = $event.target.files">
+ class="emoji-tab-popover-file input"
+ @change="uploadFile = $event.target.files"
+ >
</div>
<div>
<div class="emoji-tab-popover-input">
<label>
{{ $t('admin_dash.emoji.shortcode') }}
- <input class="emoji-data-input"
+ <input
v-model="editedShortcode"
- :placeholder="$t('admin_dash.emoji.new_shortcode')">
+ class="emoji-data-input input"
+ :placeholder="$t('admin_dash.emoji.new_shortcode')"
+ >
</label>
</div>
@@ -42,9 +55,11 @@
<label>
{{ $t('admin_dash.emoji.filename') }}
- <input class="emoji-data-input"
+ <input
v-model="editedFile"
- :placeholder="$t('admin_dash.emoji.new_filename')">
+ class="emoji-data-input input"
+ :placeholder="$t('admin_dash.emoji.new_filename')"
+ >
</label>
</div>
@@ -52,7 +67,8 @@
class="button button-default btn"
type="button"
:disabled="newUpload ? uploadFile.length == 0 : !isEdited"
- @click="newUpload ? uploadEmoji() : saveEditedEmoji()">
+ @click="newUpload ? uploadEmoji() : saveEditedEmoji()"
+ >
{{ $t('admin_dash.emoji.save') }}
</button>
@@ -60,13 +76,15 @@
<button
class="button button-default btn emoji-tab-popover-button"
type="button"
- @click="deleteModalVisible = true">
+ @click="deleteModalVisible = true"
+ >
{{ $t('admin_dash.emoji.delete') }}
</button>
<button
class="button button-default btn emoji-tab-popover-button"
type="button"
- @click="revertEmoji">
+ @click="revertEmoji"
+ >
{{ $t('admin_dash.emoji.revert') }}
</button>
<ConfirmModal
@@ -75,7 +93,8 @@
:cancel-text="$t('status.delete_confirm_cancel_button')"
:confirm-text="$t('status.delete_confirm_accept_button')"
@cancelled="deleteModalVisible = false"
- @accepted="deleteEmoji" >
+ @accepted="deleteEmoji"
+ >
{{ $t('admin_dash.emoji.delete_confirm', [shortcode]) }}
</ConfirmModal>
</template>
@@ -91,6 +110,30 @@ import StillImage from 'components/still-image/still-image.vue'
export default {
components: { Popover, ConfirmModal, StillImage },
+ inject: ['emojiAddr'],
+ props: {
+ placement: String,
+ disabled: {
+ type: Boolean,
+ default: false
+ },
+
+ newUpload: Boolean,
+
+ title: String,
+ packName: String,
+ shortcode: {
+ type: String,
+ // Only exists when this is not a new upload
+ default: ''
+ },
+ file: {
+ type: String,
+ // Only exists when this is not a new upload
+ default: ''
+ }
+ },
+ emits: ['updatePackFiles', 'displayError'],
data () {
return {
uploadFile: [],
@@ -113,7 +156,6 @@ export default {
return !this.newUpload && (this.editedShortcode !== this.shortcode || this.editedFile !== this.file)
}
},
- inject: ['emojiAddr'],
methods: {
saveEditedEmoji () {
if (!this.isEdited) return
@@ -167,29 +209,6 @@ export default {
this.$emit('updatePackFiles', resp)
})
}
- },
- emits: ['updatePackFiles', 'displayError'],
- props: {
- placement: String,
- disabled: {
- type: Boolean,
- default: false
- },
-
- newUpload: Boolean,
-
- title: String,
- packName: String,
- shortcode: {
- type: String,
- // Only exists when this is not a new upload
- default: ''
- },
- file: {
- type: String,
- // Only exists when this is not a new upload
- default: ''
- }
}
}
</script>
diff --git a/src/components/settings_modal/helpers/number_setting.vue b/src/components/settings_modal/helpers/number_setting.vue
index 93f11331..32dc6f83 100644
--- a/src/components/settings_modal/helpers/number_setting.vue
+++ b/src/components/settings_modal/helpers/number_setting.vue
@@ -15,9 +15,10 @@
</template>
<slot v-else />
</label>
+ {{ ' ' }}
<input
:id="path"
- class="number-input"
+ class="input number-input"
type="number"
:step="step || 1"
:disabled="shouldBeDisabled"
diff --git a/src/components/settings_modal/helpers/setting.js b/src/components/settings_modal/helpers/setting.js
index abf9cfdf..3b3e6268 100644
--- a/src/components/settings_modal/helpers/setting.js
+++ b/src/components/settings_modal/helpers/setting.js
@@ -48,6 +48,10 @@ export default {
draftMode: {
type: Boolean,
default: undefined
+ },
+ timedApplyMode: {
+ type: Boolean,
+ default: false
}
},
inject: {
@@ -161,7 +165,11 @@ export default {
case 'admin':
return (k, v) => this.$store.dispatch('pushAdminSetting', { path: k, value: v })
default:
- return (k, v) => this.$store.dispatch('setOption', { name: k, value: v })
+ if (this.timedApplyMode) {
+ return (k, v) => this.$store.dispatch('setOptionTemporarily', { name: k, value: v })
+ } else {
+ return (k, v) => this.$store.dispatch('setOption', { name: k, value: v })
+ }
}
},
defaultState () {
diff --git a/src/components/settings_modal/helpers/size_setting.js b/src/components/settings_modal/helpers/size_setting.js
deleted file mode 100644
index 12cef705..00000000
--- a/src/components/settings_modal/helpers/size_setting.js
+++ /dev/null
@@ -1,40 +0,0 @@
-import Select from 'src/components/select/select.vue'
-import Setting from './setting.js'
-
-export const allCssUnits = ['cm', 'mm', 'in', 'px', 'pt', 'pc', 'em', 'ex', 'ch', 'rem', 'vw', 'vh', 'vmin', 'vmax', '%']
-export const defaultHorizontalUnits = ['px', 'rem', 'vw']
-export const defaultVerticalUnits = ['px', 'rem', 'vh']
-
-export default {
- ...Setting,
- components: {
- ...Setting.components,
- Select
- },
- props: {
- ...Setting.props,
- min: Number,
- units: {
- type: Array,
- default: () => allCssUnits
- }
- },
- computed: {
- ...Setting.computed,
- stateUnit () {
- return this.state.replace(/\d+/, '')
- },
- stateValue () {
- return this.state.replace(/\D+/, '')
- }
- },
- methods: {
- ...Setting.methods,
- updateValue (e) {
- this.configSink(this.path, parseInt(e.target.value) + this.stateUnit)
- },
- updateUnit (e) {
- this.configSink(this.path, this.stateValue + e.target.value)
- }
- }
-}
diff --git a/src/components/settings_modal/helpers/string_setting.vue b/src/components/settings_modal/helpers/string_setting.vue
index 0cfa61ce..7b30d1b9 100644
--- a/src/components/settings_modal/helpers/string_setting.vue
+++ b/src/components/settings_modal/helpers/string_setting.vue
@@ -17,7 +17,7 @@
</label>
<input
:id="path"
- class="string-input"
+ class="input string-input"
:disabled="shouldBeDisabled"
:value="realDraftMode ? draft : state"
@change="update"
diff --git a/src/components/settings_modal/helpers/unit_setting.js b/src/components/settings_modal/helpers/unit_setting.js
new file mode 100644
index 00000000..daeddd81
--- /dev/null
+++ b/src/components/settings_modal/helpers/unit_setting.js
@@ -0,0 +1,64 @@
+import Select from 'src/components/select/select.vue'
+import Setting from './setting.js'
+
+export const allCssUnits = ['cm', 'mm', 'in', 'px', 'pt', 'pc', 'em', 'ex', 'ch', 'rem', 'vw', 'vh', 'vmin', 'vmax', '%']
+export const defaultHorizontalUnits = ['px', 'rem', 'vw']
+export const defaultVerticalUnits = ['px', 'rem', 'vh']
+
+export default {
+ ...Setting,
+ components: {
+ ...Setting.components,
+ Select
+ },
+ props: {
+ ...Setting.props,
+ min: Number,
+ units: {
+ type: Array,
+ default: () => allCssUnits
+ },
+ unitSet: {
+ type: String,
+ default: 'none'
+ },
+ step: {
+ type: Number,
+ default: 1
+ },
+ resetDefault: {
+ type: Object,
+ default: null
+ }
+ },
+ computed: {
+ ...Setting.computed,
+ stateUnit () {
+ return typeof this.state === 'string' ? this.state.replace(/[0-9,.]+/, '') : ''
+ },
+ stateValue () {
+ return typeof this.state === 'string' ? this.state.replace(/[^0-9,.]+/, '') : ''
+ }
+ },
+ methods: {
+ ...Setting.methods,
+ getUnitString (value) {
+ if (this.unitSet === 'none') return value
+ return this.$t(['settings', 'units', this.unitSet, value].join('.'))
+ },
+ updateValue (e) {
+ this.configSink(this.path, parseFloat(e.target.value) + this.stateUnit)
+ },
+ updateUnit (e) {
+ let value = this.stateValue
+ const newUnit = e.target.value
+ if (this.resetDefault) {
+ const replaceValue = this.resetDefault[newUnit]
+ if (replaceValue != null) {
+ value = replaceValue
+ }
+ }
+ this.configSink(this.path, value + newUnit)
+ }
+ }
+}
diff --git a/src/components/settings_modal/helpers/size_setting.vue b/src/components/settings_modal/helpers/unit_setting.vue
index 6c3fbaeb..40ab6880 100644
--- a/src/components/settings_modal/helpers/size_setting.vue
+++ b/src/components/settings_modal/helpers/unit_setting.vue
@@ -1,7 +1,7 @@
<template>
<span
v-if="matchesExpertLevel"
- class="SizeSetting"
+ class="UnitSetting"
>
<label
:for="path"
@@ -9,11 +9,12 @@
>
<slot />
</label>
+ {{ ' ' }}
<input
:id="path"
- class="number-input"
+ class="input number-input"
type="number"
- step="1"
+ :step="step"
:disabled="disabled"
:min="min || 0"
:value="stateValue"
@@ -23,7 +24,7 @@
:id="path"
:model-value="stateUnit"
:disabled="disabled"
- class="css-unit-input"
+ class="unit-input unstyled"
@change="updateUnit"
>
<option
@@ -31,7 +32,7 @@
:key="option"
:value="option"
>
- {{ option }}
+ {{ getUnitString(option) }}
</option>
</Select>
{{ ' ' }}
@@ -42,20 +43,19 @@
</span>
</template>
-<script src="./size_setting.js"></script>
+<script src="./unit_setting.js"></script>
<style lang="scss">
-.SizeSetting {
+.UnitSetting {
.number-input {
max-width: 6.5em;
+ text-align: right;
}
- .css-unit-input,
- .css-unit-input select {
- margin-left: 0.5em;
- width: 4em;
- max-width: 4em;
+ .unit-input,
+ .unit-input select {
min-width: 4em;
+ width: auto;
}
}