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

Commit

Permalink
Sióme minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
emptynick committed Jun 2, 2019
1 parent a0a8cd8 commit ce348a4
Show file tree
Hide file tree
Showing 7 changed files with 28,009 additions and 12 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ composer require emptynick/voyager-bread
That's it. No installation or configuration is required.
Navigate to your adminpanel and go to `Tools > BREAD`

## Formfields:
## Formfields

- [X] Text / Textarea
- [X] Number
Expand All @@ -22,3 +22,7 @@ Navigate to your adminpanel and go to `Tools > BREAD`
- [ ] Select
- [ ] Date/Time/Datetime
- [ ] Relationships

## Bugs

- Deleting List elements
6 changes: 3 additions & 3 deletions resources/assets/components/Formfields/BaseFormfield.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="panel-heading" v-if="view == 'mockup'">
<h3 class="panel-title">{{ type.charAt(0).toUpperCase() + type.slice(1) }}, Field: {{ options.field || 'none' }}</h3>
<div class="panel-actions">
<a class="panel-action voyager-trash" @click="$parent.$parent.deleteFormfield($vnode.key)"></a>
<a class="panel-action voyager-trash" @click="$parent.deleteFormfield($vnode.key)"></a>
<a class="panel-action voyager-settings open-settings" @click="optionsOpen = !optionsOpen"></a>
<a class="panel-action voyager-code" @mousedown="startResize()" @mouseup="endResize()"></a>
<a class="panel-action voyager-handle drag_handle"></a>
Expand Down Expand Up @@ -68,7 +68,7 @@
</div>
<label v-if="options.title">{{ getTranslation(options.title, view != 'mockup') }}</label>
<component :is="'formfield-'+type" :view="view" :options="options" :layout-type="layoutType" :base="this" />
<input type="hidden" :name="options.field" :value="getTranslatedValue()">
<input type="text" :name="options.field" :value="getTranslatedValue()">
<span v-if="options.help_text && view != 'read'">{{ getTranslation(options.help_text, view != 'mockup') }}</span>
</div>
</div>
Expand Down Expand Up @@ -120,7 +120,7 @@
<div slot="reference"></div>
</popper>
<button class="btn btn-primary" @click="optionsOpen = !optionsOpen">Options</button>
<button class="btn btn-danger" @click="$parent.$parent.deleteFormfield($vnode.key)">Delete</button>
<button class="btn btn-danger" @click="$parent.deleteFormfield($vnode.key)">Delete</button>
</div>
</div>
<component v-else :is="'formfield-'+type" :view="view" :options="options" :base="this" />
Expand Down
26,972 changes: 26,971 additions & 1 deletion resources/assets/dist/scripts.js

Large diffs are not rendered by default.

1,012 changes: 1,011 additions & 1 deletion resources/assets/dist/styles.css

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions resources/views/manager/edit-add.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@include('voyager::alerts')
<div class="row">
<div class="col-md-12">
<div class="panel panel-primary panel-bordered">
<div class="panel panel-primary panel-bordered">
<div class="panel-heading">
<h3 class="panel-title panel-icon"><i class="voyager-info-circled"></i> {{ ucfirst($table) }} {{ __('voyager::bread.bread_info') }}</h3>
<div class="panel-actions">
Expand Down Expand Up @@ -66,7 +66,7 @@
</div>
</div><!-- .panel-body -->
</div><!-- .panel -->
<div class="panel panel-primary panel-bordered">
<div class="panel panel-primary panel-bordered">
<div class="panel-heading">
<h3 class="panel-title panel-icon"><i class="voyager-bread"></i> Layout Builder</h3>
<div class="panel-actions">
Expand Down Expand Up @@ -141,7 +141,7 @@
</div>
</div>
</div>
<div class="panel panel-primary panel-bordered">
<div class="panel panel-primary panel-bordered">
<div class="panel-heading">
<h3 class="panel-title panel-icon"><i class="voyager-lock"></i> Roles</h3>
<div class="panel-actions">
Expand Down Expand Up @@ -196,7 +196,7 @@
</div>
</div>
</div>
<div class="panel panel-primary panel-bordered">
<div class="panel panel-primary panel-bordered">
<div class="panel-heading">
<h3 class="panel-title panel-icon"><i class="voyager-code"></i> Code</h3>
<div class="panel-actions">
Expand Down Expand Up @@ -340,4 +340,4 @@

@section('css')
<link rel="stylesheet" href="{{ route('voyager.bread.styles') }}">
@endsection
@endsection
2 changes: 1 addition & 1 deletion src/Formfields/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Number extends BaseFormfield

public function update($value)
{
return number_format($value, $this->options->decimals ?? 0);
return number_format(floatval($value), $this->options->decimals ?? 0);
}

public function store($value)
Expand Down
13 changes: 13 additions & 0 deletions src/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,20 @@ public function processData(Request $request, $layout, $action, $data)
{
$layout->formfields->each(function ($formfield) use ($request, $action, &$data) {
$field = $formfield->options->field ?? null;
$translatable = $formfield->options->translatable ?? false;
if ($field) {
if ($translatable) {
$json = @json_decode($request->get($field));
if (json_last_error() == JSON_ERROR_NONE && is_array($json)) {
$newVal = [];
foreach ($json as $locale => $str) {
$newVal[$locale] = $formfield->$action($str);
}
$data->{$field} = json_encode($newVal);

return;
}
}
$data->{$field} = $formfield->$action($request->get($field) ?? $data->{$field});
}
});
Expand Down

0 comments on commit ce348a4

Please sign in to comment.