Skip to content

Commit

Permalink
Name method and Localization
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Lagarda committed Nov 14, 2019
1 parent cc6ffd0 commit 37f5e55
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 5 deletions.
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# Nova Settings Card


Expand Down Expand Up @@ -25,8 +26,24 @@ KeyValue::make('Meta')->resolveUsing(function ($value) {
composer require ericlagarda/nova-settings-card
```

2. Publish [akaunting/setting](https://github.com/akaunting/setting) config and migrations

```php
php artisan vendor:publish --tag=setting
```

3. Migrate settings table
```php
php artisan migrate
```

4. Add SettingsCard to your own Nova Dashboard

Available methods:

* **fields** -> Tabbed nova fields
* **name** -> Card name

2. Add SettingsCard to your own Nova Dashboard

```php
use EricLagarda\SettingsCard\SettingsCard;
Expand Down Expand Up @@ -58,9 +75,18 @@ KeyValue::make('Meta')->resolveUsing(function ($value) {
Code::make('Header Styles')->language('sass'),
Code::make('Footer Styles')->language('sass'),
],
]),
])->name('My settings card'),
];

...
}
```
You can set the name of the card with `name()` functions. Default to `Settings`.

## Localization

```json
"Settings": "Opciones",
"Save settings": "Guardar opciones",
"Settings saved! - Reloading page.": "¡opciones guardadas! - Recargando la página..."
```
2 changes: 1 addition & 1 deletion dist/js/card.js

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion resources/js/components/Card.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="">

<h1 class="mb-3 text-90 font-normal text-2xl flex">Settings</h1>
<h1 class="mb-3 text-90 font-normal text-2xl flex">{{ cardName }}</h1>

<card >
<div class="tabs-wrap border-b-2 border-40 w-full">
Expand Down Expand Up @@ -93,6 +93,16 @@ export default {
this.card.fields[0].init = true;
},
computed: {
cardName() {
if (this.card.name) {
return this.card.name
}
return this.__('Settings')
}
},
methods: {
handleTabClick(tab, event) {
tab.init = true;
Expand Down
16 changes: 15 additions & 1 deletion src/SettingsCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace EricLagarda\SettingsCard;

use Illuminate\Support\Str;
use Laravel\Nova\Card;

class SettingsCard extends Card
Expand All @@ -19,6 +20,8 @@ class SettingsCard extends Card
protected $disks = [];

/**
* Set the card fields
*
* @param array $fields
* @return mixed
*/
Expand All @@ -30,6 +33,17 @@ public function fields(array $fields)
]);
}

/**
* Set Name of the card
*
* @param string $name
* @return mixed
*/
public function name(string $name)
{
return $this->withMeta(['name' => $name]);
}

/**
* Get the component name for the element.
*
Expand Down Expand Up @@ -92,7 +106,7 @@ private function parseFieldsToTabs(array $fields): array
foreach ($fields as $tab => $fields) {
$tabs[] = [
'name' => $tab,
'key' => str_slug($tab),
'key' => Str::slug($tab),
'fields' => $fields,
'init' => false,
];
Expand Down

0 comments on commit 37f5e55

Please sign in to comment.