Skip to content
Snippets Groups Projects
Commit 44665aa0 authored by Griefed's avatar Griefed :joystick:
Browse files

refactor: Set width of filefield to max. Add tooltips for various parts....

refactor: Set width of filefield to max. Add tooltips for various parts. Implement more checks for chosen file and notifications on rejection.
parent de46fb44
No related branches found
No related tags found
1 merge request!28File load closes issue #22
...@@ -33,6 +33,9 @@ ...@@ -33,6 +33,9 @@
</q-item-section> </q-item-section>
<q-item-section> <q-item-section>
<q-slider v-model="store.state.mapSizeX" :min="1" :max="101" label color="secondary" :step="1" label-always/> <q-slider v-model="store.state.mapSizeX" :min="1" :max="101" label color="secondary" :step="1" label-always/>
<q-tooltip :disable="$q.platform.is.mobile">
Size along the X-axis.
</q-tooltip>
</q-item-section> </q-item-section>
</q-item> </q-item>
...@@ -42,6 +45,9 @@ ...@@ -42,6 +45,9 @@
</q-item-section> </q-item-section>
<q-item-section> <q-item-section>
<q-slider v-model="store.state.mapSizeY" :min="1" :max="101" label color="secondary" :step="1" label-always/> <q-slider v-model="store.state.mapSizeY" :min="1" :max="101" label color="secondary" :step="1" label-always/>
<q-tooltip :disable="$q.platform.is.mobile">
Size along the Y-axis.
</q-tooltip>
</q-item-section> </q-item-section>
</q-item> </q-item>
...@@ -61,6 +67,9 @@ ...@@ -61,6 +67,9 @@
<q-icon name="cancel" @click.stop="store.state.seed = null" class="cursor-pointer" /> <q-icon name="cancel" @click.stop="store.state.seed = null" class="cursor-pointer" />
<q-icon name="refresh" @click.stop="store.state.seed = store.seedGenerator.random_int31()" class="cursor-pointer" /> <q-icon name="refresh" @click.stop="store.state.seed = store.seedGenerator.random_int31()" class="cursor-pointer" />
</template> </template>
<q-tooltip :disable="$q.platform.is.mobile">
Numbers only.
</q-tooltip>
</q-input> </q-input>
<q-btn class="q-mr-xs" color="secondary" label="Generate Random Map" @click='createRandomMap()'> <q-btn class="q-mr-xs" color="secondary" label="Generate Random Map" @click='createRandomMap()'>
<q-tooltip :disable="$q.platform.is.mobile"> <q-tooltip :disable="$q.platform.is.mobile">
...@@ -79,7 +88,11 @@ ...@@ -79,7 +88,11 @@
placeholder="Paste Map Data" placeholder="Paste Map Data"
type="textarea" type="textarea"
input-class="pastCodeArea" input-class="pastCodeArea"
></q-input> >
<q-tooltip :disable="$q.platform.is.mobile">
Valid map-json only.
</q-tooltip>
</q-input>
<q-btn class="q-mr-xs" color="secondary" label="Load Map From Filedata" @click='loadMapData()'> <q-btn class="q-mr-xs" color="secondary" label="Load Map From Filedata" @click='loadMapData()'>
<q-tooltip :disable="$q.platform.is.mobile"> <q-tooltip :disable="$q.platform.is.mobile">
Load Map From Data Load Map From Data
...@@ -95,12 +108,19 @@ ...@@ -95,12 +108,19 @@
v-model="file" v-model="file"
label="Pick one file" label="Pick one file"
filled filled
accept=".json" clearable
style="max-width: 300px" accept=".json, application/*"
/> max-file-size="800000"
style="max-width: 100%"
@rejected="onRejected"
>
<q-tooltip :disable="$q.platform.is.mobile">
Only one file of max 800Kb in size.
</q-tooltip>
</q-file>
<q-btn class="q-mr-xs" color="secondary" label="Load Map From Filedata" @click='loadMapFile()'> <q-btn class="q-mr-xs" color="secondary" label="Load Map From Filedata" @click='loadMapFile()'>
<q-tooltip :disable="$q.platform.is.mobile"> <q-tooltip :disable="$q.platform.is.mobile">
Load Map From Data Load Map From File
</q-tooltip> </q-tooltip>
</q-btn> </q-btn>
</div> </div>
...@@ -169,6 +189,13 @@ export default defineComponent({ ...@@ -169,6 +189,13 @@ export default defineComponent({
store.methods.generateRandomMap(); store.methods.generateRandomMap();
}; };
const onRejected = function(rejectedEntries) {
$q.notify({
type: 'negative',
message: `${rejectedEntries[0].file.name} file(s) did not pass validation constraints`
});
};
return { return {
parseJsonFromString, parseJsonFromString,
file: ref(null), file: ref(null),
...@@ -177,7 +204,8 @@ export default defineComponent({ ...@@ -177,7 +204,8 @@ export default defineComponent({
createMap, createMap,
createRandomMap, createRandomMap,
loadMapData, loadMapData,
loadMapFile loadMapFile,
onRejected
} }
}, },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment