Skip to content
This repository was archived by the owner on Dec 6, 2019. It is now read-only.

Commit

Permalink
Major updates
Browse files Browse the repository at this point in the history
  • Loading branch information
emptynick committed Oct 19, 2018
1 parent 8fe1024 commit acceabe
Show file tree
Hide file tree
Showing 41 changed files with 554 additions and 302 deletions.
2 changes: 1 addition & 1 deletion .gitbook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ root: ./docs/

structure:
readme: ./introduction.md
summary: ./_summary.md
summary: ./summary.md
5 changes: 0 additions & 5 deletions SUMMARY.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/_summary.md → docs/summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@

* [Setup](translations/setup.md)
* [Usage](translations/usage.md)

28 changes: 7 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 6 additions & 11 deletions publishable/config/bread.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
<?php

//https://christoph-schweppe.gitbook.io/voyager-bread/getting-started/configurations
return [
'bread_path' => storage_path('bread'),

/* Default palette of the color-picker.
* Can be an array of colors, eg:
'colors' => [
'#FF0000', '#00FF00', '#0000FF', ''
],
* (use an empty string for transparent)
* or one of this presets as a string:
* basic, text-basic, text-advanced, material-basic, material-light, material-dark
*/
'colors' => 'material-basic',
'colors' => 'material-basic',
'bread_buttons' => [
'save_edit' => true,
'save_new' => true,
]
];
76 changes: 63 additions & 13 deletions resources/views/bread/browse.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,26 @@
<i class="voyager-trash"></i> <span>{{ __('voyager::generic.bulk_delete') }}</span>
</a>
@endcan
@if ($model->isTranslatable)
<language-switcher :languages="{{ json_encode(config('voyager.multilingual.locales')) }}"></language-switcher>
@endif
</div>
<div class="page-content browse container-fluid">
@include('voyager::alerts')
<div class="row">
<div class="col-md-12">
<div class="panel panel-bordered">
<div class="panel-body">
<v-server-table url="{{ route('voyager.'.$bread->slug.'.data') }}" :columns="columns" :options="options" ref="browse_table">
<v-server-table :url="tableUrl" :columns="columns" :options="options" ref="browse_table">
<template v-for="col in this.columns" :slot="col" slot-scope="props">
<component
:is="'formfield-'+props.row[col].type"
:options="JSON.parse(props.row[col].options)"
:name="''"
:show="'browse'"
:input="props.row[col].data"
></component>
</template>
<div slot="h__bread_delete">
@can('delete', $model)
<input type="checkbox" id="select_all_checkbox" v-model="selectAll" v-on:click="toggleSelectAll()">
Expand All @@ -48,24 +60,31 @@
</a>
@endcan
@can('delete', $model)
<a href="#" class="btn btn-sm btn-danger" v-on:click="deleteEntry(props.row.bread_delete)">
<a href="#" @if ($soft_delete)v-if="!props.row.deleted_at"@endif class="btn btn-sm btn-danger" v-on:click="deleteEntry(props.row.bread_delete)">
<i class="voyager-trash"></i> <span class="hidden-xs hidden-sm">{{ __('voyager::generic.delete') }}</span>
</a>
@if ($soft_delete)
<a href="#" v-if="props.row.deleted_at" class="btn btn-sm btn-success" v-on:click="restoreEntry(props.row.restore)">
<i class="voyager-trash"></i> <span class="hidden-xs hidden-sm">Restore</span>
</a>
@endif
@endcan
</div>
<div slot="h__bread_actions">
<div class="pull-right">Actions</div>
</div>
<div slot="{{ $model->getKeyName() }}" slot-scope="props">
@can('read', $model)
<a :href="props.row.bread_read">{{ props.row.<?php echo $model->getKeyName(); ?> }}</a>
@else
@can('edit', $model)
<a :href="props.row.bread_edit">{{ props.row.<?php echo $model->getKeyName(); ?> }}</a>
@else
{{ props.row.<?php echo $model->getKeyName(); ?> }}
@endcan
@endcan

<div slot="beforeLimit">
@if ($soft_delete)
<div v-if="this.layout.trashed == 'select'">
Trashed:
<select class="form-control" v-model="withTrashed">
<option value="no">No</option>
<option value="yes">Yes</option>
<option value="only">Only</option>
</select>
</div>
@endif
</div>
</v-server-table>
</div>
Expand All @@ -78,12 +97,18 @@

@section('javascript')
<script src="{{ route('voyager.bread.scripts') }}"></script>
@foreach(\Bread\BreadFacade::formfields() as $formfield)
@include($formfield->getComponent('view'))
@endforeach
@include('bread::components.language-switcher')
<script>
new Vue({
el: "#bread-browse",
data: {
withTrashed: 'no',
deleteIds: [],
selectAll: false,
layout: {!! collect($layout)->toJson() !!},
columns: {!! $layout->elements->pluck('field')->prepend('bread_delete')->push('bread_actions')->toJson() !!},
options: {
filterByColumn: true,
Expand Down Expand Up @@ -119,6 +144,7 @@
defaultOption: 'Select {column}',
},
},
tableUrl: "{{ route('voyager.'.$bread->slug.'.data') }}",
},
methods: {
toggleSelectAll: function() {
Expand Down Expand Up @@ -167,8 +193,32 @@
{text: '{{ __("voyager::generic.no") }}', action: (toast) => this.$snotify.remove(toast.id) },
]
});
},
restoreEntry: function(url) {
this.$snotify.confirm('Are you sure you want to restore this {{ $bread->display_name_singular }}?', 'Restore {{ $bread->display_name_singular }}?', {
timeout: 5000,
showProgressBar: true,
closeOnClick: false,
pauseOnHover: true,
buttons: [
{text: '{{ __("voyager::generic.yes") }}', action: (toast) => {
this.$http.post(url, { _token: '{{ csrf_token() }}' }).then(response => {
this.$refs.browse_table.refresh();
this.$snotify.remove(toast.id);
}, response => {
//
});
}, bold: false},
{text: '{{ __("voyager::generic.no") }}', action: (toast) => this.$snotify.remove(toast.id) },
]
});
},
},
watch: {
withTrashed: function(value) {
this.tableUrl = "{{ route('voyager.'.$bread->slug.'.data') }}?withTrashed="+value;
}
}
},
});
</script>
@endsection
Expand Down
8 changes: 6 additions & 2 deletions resources/views/bread/edit-add.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,16 @@
</div>
</div>
<div class="panel-footer">
<button type="submit" name="submit_action" value="" class="btn btn-primary">{{ __('voyager::generic.save') }}</button>
<button type="submit" name="submit_action" value="" class="btn btn-primary">Save</button>
@can('edit', $model)
<button type="submit" name="submit_action" value="edit" class="btn btn-primary">Save and Edit</button>
@if (config('bread.bread_buttons.save_edit', true))
<button type="submit" name="submit_action" value="edit" class="btn btn-primary">Save and edit</button>
@endif
@endcan
@can('add', $model)
@if (config('bread.bread_buttons.save_new', true))
<button type="submit" name="submit_action" value="add" class="btn btn-primary">Save and create new</button>
@endif
@endcan
</div>
</div>
Expand Down
37 changes: 37 additions & 0 deletions resources/views/components/language-input.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@section('language-input')
<div>
<input v-model="translate"
:type="this.type"
class="form-control"
:name="name+'_faker'"
:placeholder="this.placeholder">
<input type="hidden" :name="name" v-model="translationString">
</div>
@endsection

<script>
Vue.component('language-input', {
template: `@yield('language-input')`,
props: ['languages', 'input', 'name', 'type', 'placeholder', 'slug_from'],
created: function() {
this.setInitialTranslation(
(this.input == null ? '' : this.input),
'{{ app()->getLocale() }}',
{!! json_encode(config('voyager.multilingual.locales')) !!},
true
);
},
watch: {
translate: function (newVal, oldVal) {
this.$bus.$emit(this.name+'_change', newVal, oldVal);
}
},
mounted: function() {
this.$bus.$on(this.slug_from+'_change', (newVal, oldVal) => {
if (this.slug_from != '' && typeof oldVal === 'string') {
this.translate = Vue.slugify(newVal);
}
});
},
});
</script>
3 changes: 1 addition & 2 deletions resources/views/formfields/dynamicselect.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
</div>
<div v-else>
<label v-if="options.title.length > 0">@{{ options.title }}</label>
<multiselect v-model="ttt" :options="options.options" track-by="key" label="value" :multiselect="options.multiple">
</multiselect>

<small v-if="options.help_text.length > 0">@{{ options.help_text }}</small>
</div>
</div>
Expand Down
16 changes: 13 additions & 3 deletions resources/views/formfields/maskedinput.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
:mask="options.mask"
:placeholder="options.placeholder"
:placeholderChar="options.mask_char"
v-model="translate"
class="form-control" />
<input type="hidden" :name="name" v-model="translationString">
<small v-if="options.help_text.length > 0">@{{ options.help_text }}</small>
</div>
</div>
Expand All @@ -63,9 +65,17 @@ class="form-control" />
Vue.component('formfield-maskedinput', {
template: `@yield('maskedinput')`,
props: ['show', 'options', 'type', 'fields', 'name', 'input'],
data: function() {
return {
'value': (this.input == null ? this.options.default_value : this.input),
created: function() {
this.setInitialTranslation(
(this.input == null ? this.options.default_value : this.input),
'{{ app()->getLocale() }}',
{!! json_encode(config('voyager.multilingual.locales')) !!},
this.options.isTranslatable
);
},
watch: {
translate: function (newVal, oldVal) {
this.$bus.$emit(this.name+'_change', newVal, oldVal);
}
},
});
Expand Down
Loading

0 comments on commit acceabe

Please sign in to comment.