Skip to content

Commit 477bbbc

Browse files
committed
Update
- Added : return exact string for unmatched translation - Fixed : create symbolic link on windows for language - Fixed : flat array with keys - Added : new hook when crud form is loaded - Added : new filter when crud footer form is rendered - Added : new filter when settings footer is rendered
1 parent 6266fdd commit 477bbbc

File tree

7 files changed

+41
-9
lines changed

7 files changed

+41
-9
lines changed

app/Services/HelperFunctions.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ function ns(): CoreService {
199199
* @param string $namespace
200200
* @return string $result
201201
*/
202-
function __m( $key, $namespace ) {
203-
return app( 'translator' )->get( $namespace . '.' . $key );
202+
function __m( $key, $namespace = 'default' ) {
203+
if ( app( 'translator' )->has( $namespace . '.' . $key ) ) {
204+
return app( 'translator' )->get( $namespace . '.' . $key );
205+
}
206+
207+
return $key;
204208
}

app/Services/Helpers/ArrayHelper.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,11 @@ static function flatArrayWithKeys( $data )
137137
if ( ! is_array( $data ) || is_numeric( $index ) ) {
138138
return [ $index => $data ];
139139
} else if ( is_array( $data ) ) {
140-
return self::flatArrayWithKeys( $data );
140+
if ( array_keys( $data ) !== range(0, count( $data ) - 1) ) {
141+
return self::flatArrayWithKeys( $data );
142+
} else {
143+
return [ $index => json_encode( $data ) ];
144+
}
141145
}
142146

143147
return [];

app/Services/ModulesService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ public function createSymLink( $moduleNamespace )
760760
} else {
761761
$mode = 'J';
762762
$link = public_path( 'modules-lang' . DIRECTORY_SEPARATOR . strtolower( $moduleNamespace ) );
763-
$target = base_path( 'modules' . DIRECTORY_SEPARATOR . $moduleNamespace . DIRECTORY_SEPARATOR . 'Public' );
763+
$target = base_path( 'modules' . DIRECTORY_SEPARATOR . $moduleNamespace . DIRECTORY_SEPARATOR . 'Lang' );
764764
$link = exec("mklink /{$mode} \"{$link}\" \"{$target}\"");
765765
}
766766
}

app/Services/OrdersService.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ private function __saveOrderProducts($order, $products)
960960
$taxes = 0;
961961
$gross = 0;
962962

963-
$products->each(function ($product) use (&$subTotal, &$taxes, &$order, &$gross) {
963+
$orderProducts = $products->map(function ($product) use (&$subTotal, &$taxes, &$order, &$gross) {
964964

965965
/**
966966
* storing the product
@@ -1040,9 +1040,11 @@ private function __saveOrderProducts($order, $products)
10401040
}
10411041

10421042
event( new OrderProductAfterSavedEvent( $orderProduct, $order, $product ) );
1043+
1044+
return $orderProduct;
10431045
});
10441046

1045-
return compact('subTotal', 'taxes', 'order');
1047+
return compact('subTotal', 'taxes', 'order', 'orderProducts' );
10461048
}
10471049

10481050
private function __buildOrderProducts( $products )
@@ -1691,8 +1693,12 @@ public function addProducts(Order $order, $products)
16911693
* let's save the products
16921694
* to the order now as the stock
16931695
* seems to be okay
1696+
* @param array $orderProducts
1697+
* @param Order $order
1698+
* @param float $taxes
1699+
* @param float $subTotal
16941700
*/
1695-
$this->__saveOrderProducts($order, $products);
1701+
extract( $this->__saveOrderProducts( $order, $products ) );
16961702

16971703
/**
16981704
* Now we should refresh the order
@@ -1702,6 +1708,7 @@ public function addProducts(Order $order, $products)
17021708

17031709
return [
17041710
'status' => 'success',
1711+
'data' => compact( 'orderProducts', 'order' ),
17051712
'message' => sprintf(
17061713
__('The product has been added to the order "%s"'),
17071714
$order->code

resources/ts/components/ns-crud-form.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { nsHttpClient, nsSnackBar } from '../bootstrap';
1+
import { nsHooks, nsHttpClient, nsSnackBar } from '../bootstrap';
22
import Vue from 'vue';
33
import FormValidation from '../libraries/form-validation';
44

@@ -72,7 +72,6 @@ const nsCrudForm = Vue.component( 'ns-crud-form', {
7272
}).subscribe();
7373

7474
this.formValidation.triggerError( this.form, error );
75-
7675
this.formValidation.enableForm( this.form );
7776
})
7877
},
@@ -84,6 +83,7 @@ const nsCrudForm = Vue.component( 'ns-crud-form', {
8483
const request = nsHttpClient.get( `${this.src}` );
8584
request.subscribe( (f:any) => {
8685
this.form = this.parseForm( f.form );
86+
nsHooks.doAction( 'ns-crud-form-loaded', this );
8787
this.$emit( 'updated', this.form );
8888
}, ( error ) => {
8989
nsSnackBar.error( error.message, 'OKAY', { duration: 0 }).subscribe();

resources/views/pages/dashboard/crud/form.blade.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<?php
2+
use App\Classes\Hook;
3+
use App\Classes\Output;
4+
?>
15
@extends( 'layout.dashboard' )
26

37
@section( 'layout.dashboard.body' )
@@ -20,4 +24,9 @@
2024
</ns-crud-form>
2125
</div>
2226
</div>
27+
@endsection
28+
29+
@section( 'layout.dashboard.footer' )
30+
@parent
31+
{!! ( string ) Hook::filter( 'ns-crud-form-footer', new Output ) !!}
2332
@endsection

resources/views/pages/dashboard/settings/form.blade.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
<?php
2+
use App\Classes\Output;
3+
?>
14
@extends( 'layout.dashboard' )
25

36
@section( 'layout.dashboard.body' )
@@ -20,4 +23,9 @@
2023
</div>
2124
</div>
2225
</div>
26+
@endsection
27+
28+
@section( 'layout.dashboard.footer' )
29+
@parent
30+
{!! ( string ) Hook::filter( 'ns-settings-footer', new Output, $identifier ) !!}
2331
@endsection

0 commit comments

Comments
 (0)