Commit c0923cbd authored by Phil Hughes's avatar Phil Hughes

added quick create new file buttons to modal

parent 7465f62e
<script>
import $ from 'jquery';
import { __ } from '~/locale';
import { mapActions, mapState } from 'vuex';
import { mapActions, mapState, mapGetters } from 'vuex';
import GlModal from '~/vue_shared/components/gl_modal.vue';
import { modalTypes } from '../../constants';
......@@ -15,6 +16,7 @@ export default {
},
computed: {
...mapState(['entryModal']),
...mapGetters('fileTemplates', ['templateTypes']),
entryName: {
get() {
if (this.entryModal.type === modalTypes.rename) {
......@@ -31,7 +33,9 @@ export default {
if (this.entryModal.type === modalTypes.tree) {
return __('Create new directory');
} else if (this.entryModal.type === modalTypes.rename) {
return this.entryModal.entry.type === modalTypes.tree ? __('Rename folder') : __('Rename file');
return this.entryModal.entry.type === modalTypes.tree
? __('Rename folder')
: __('Rename file');
}
return __('Create new file');
......@@ -40,7 +44,9 @@ export default {
if (this.entryModal.type === modalTypes.tree) {
return __('Create directory');
} else if (this.entryModal.type === modalTypes.rename) {
return this.entryModal.entry.type === modalTypes.tree ? __('Rename folder') : __('Rename file');
return this.entryModal.entry.type === modalTypes.tree
? __('Rename folder')
: __('Rename file');
}
return __('Create file');
......@@ -61,6 +67,14 @@ export default {
});
}
},
createFromTemplate(template) {
this.createTempEntry({
name: template.name,
type: this.entryModal.type,
});
$('#ide-new-entry').modal('toggle');
},
focusInput() {
this.$refs.fieldName.focus();
},
......@@ -84,16 +98,32 @@ export default {
<div
class="form-group row"
>
<label class="label-bold col-form-label col-sm-3">
<label class="label-bold col-form-label col-sm-2">
{{ __('Name') }}
</label>
<div class="col-sm-9">
<div class="col-sm-10">
<input
ref="fieldName"
v-model="entryName"
type="text"
class="form-control"
placeholder="/dir/file_name"
/>
<ul class="prepend-top-default list-inline">
<li
v-for="(template, index) in templateTypes"
:key="index"
class="list-inline-item"
>
<button
type="button"
class="btn btn-missing p-1 pr-2 pl-2"
@click="createFromTemplate(template)"
>
{{ template.name }}
</button>
</li>
</ul>
</div>
</div>
</gl-modal>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment