Commit c0923cbd authored by Phil Hughes's avatar Phil Hughes

added quick create new file buttons to modal

parent 7465f62e
<script> <script>
import $ from 'jquery';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { mapActions, mapState } from 'vuex'; import { mapActions, mapState, mapGetters } from 'vuex';
import GlModal from '~/vue_shared/components/gl_modal.vue'; import GlModal from '~/vue_shared/components/gl_modal.vue';
import { modalTypes } from '../../constants'; import { modalTypes } from '../../constants';
...@@ -15,6 +16,7 @@ export default { ...@@ -15,6 +16,7 @@ export default {
}, },
computed: { computed: {
...mapState(['entryModal']), ...mapState(['entryModal']),
...mapGetters('fileTemplates', ['templateTypes']),
entryName: { entryName: {
get() { get() {
if (this.entryModal.type === modalTypes.rename) { if (this.entryModal.type === modalTypes.rename) {
...@@ -31,7 +33,9 @@ export default { ...@@ -31,7 +33,9 @@ export default {
if (this.entryModal.type === modalTypes.tree) { if (this.entryModal.type === modalTypes.tree) {
return __('Create new directory'); return __('Create new directory');
} else if (this.entryModal.type === modalTypes.rename) { } 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'); return __('Create new file');
...@@ -40,7 +44,9 @@ export default { ...@@ -40,7 +44,9 @@ export default {
if (this.entryModal.type === modalTypes.tree) { if (this.entryModal.type === modalTypes.tree) {
return __('Create directory'); return __('Create directory');
} else if (this.entryModal.type === modalTypes.rename) { } 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'); return __('Create file');
...@@ -61,6 +67,14 @@ export default { ...@@ -61,6 +67,14 @@ export default {
}); });
} }
}, },
createFromTemplate(template) {
this.createTempEntry({
name: template.name,
type: this.entryModal.type,
});
$('#ide-new-entry').modal('toggle');
},
focusInput() { focusInput() {
this.$refs.fieldName.focus(); this.$refs.fieldName.focus();
}, },
...@@ -84,16 +98,32 @@ export default { ...@@ -84,16 +98,32 @@ export default {
<div <div
class="form-group row" 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') }} {{ __('Name') }}
</label> </label>
<div class="col-sm-9"> <div class="col-sm-10">
<input <input
ref="fieldName" ref="fieldName"
v-model="entryName" v-model="entryName"
type="text" type="text"
class="form-control" 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>
</div> </div>
</gl-modal> </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