Skip to content

Commit

Permalink
Merge pull request #110 from fleetbase/dev-v0.4.29
Browse files Browse the repository at this point in the history
dev-v0.4.29
  • Loading branch information
roncodes authored May 17, 2024
2 parents 721b909 + bb9b1f4 commit de16599
Show file tree
Hide file tree
Showing 38 changed files with 590 additions and 144 deletions.
3 changes: 2 additions & 1 deletion addon/controllers/management/contacts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ export default class ManagementContactsIndexController extends BaseController {
* @void
*/
@action exportContacts() {
this.crud.export('contact');
const selections = this.table.selectedRows.map((_) => _.id);
this.crud.export('contact', { params: { selections } });
}

/**
Expand Down
3 changes: 2 additions & 1 deletion addon/controllers/management/drivers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,8 @@ export default class ManagementDriversIndexController extends BaseController {
* @void
*/
@action exportDrivers() {
this.crud.export('driver');
const selections = this.table.selectedRows.map((_) => _.id);
this.crud.export('driver', { params: { selections } });
}

/**
Expand Down
3 changes: 2 additions & 1 deletion addon/controllers/management/fleets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,8 @@ export default class ManagementFleetsIndexController extends BaseController {
* @void
*/
@action exportFleets() {
this.crud.export('fleet');
const selections = this.table.selectedRows.map((_) => _.id);
this.crud.export('fleet', { params: { selections } });
}

/**
Expand Down
3 changes: 2 additions & 1 deletion addon/controllers/management/issues/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ export default class ManagementIssuesIndexController extends BaseController {
* @void
*/
@action exportIssues() {
this.crud.export('issue');
const selections = this.table.selectedRows.map((_) => _.id);
this.crud.export('issue', { params: { selections } });
}

/**
Expand Down
3 changes: 2 additions & 1 deletion addon/controllers/management/places/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ export default class ManagementPlacesIndexController extends BaseController {
* @void
*/
@action exportPlaces() {
this.crud.export('place');
const selections = this.table.selectedRows.map((_) => _.id);
this.crud.export('place', { params: { selections } });
}

/**
Expand Down
3 changes: 2 additions & 1 deletion addon/controllers/management/vehicles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,8 @@ export default class ManagementVehiclesIndexController extends BaseController {
* @void
*/
@action exportVehicles() {
this.crud.export('vehicle');
const selections = this.table.selectedRows.map((_) => _.id);
this.crud.export('vehicle', { params: { selections } });
}

/**
Expand Down
3 changes: 2 additions & 1 deletion addon/controllers/management/vendors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@ export default class ManagementVendorsIndexController extends BaseController {
* @void
*/
@action exportVendors() {
this.crud.export('vendor');
const selections = this.table.selectedRows.map((_) => _.id);
this.crud.export('vendor', { params: { selections } });
}

/**
Expand Down
3 changes: 2 additions & 1 deletion addon/controllers/operations/orders/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,8 @@ export default class OperationsOrdersIndexController extends BaseController {
* @memberof OperationsOrdersIndexController
*/
@action exportOrders() {
this.crud.export('order');
const selections = this.table.selectedRows.map((_) => _.id);
this.crud.export('order', { params: { selections } });
}

/**
Expand Down
3 changes: 2 additions & 1 deletion addon/controllers/operations/service-rates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ export default class OperationsServiceRatesIndexController extends BaseControlle
* @void
*/
@action exportServiceRates() {
this.crud.export('service-rate');
const selections = this.table.selectedRows.map((_) => _.id);
this.crud.export('service-rate', { params: { selections } });
}

/**
Expand Down
11 changes: 2 additions & 9 deletions addon/templates/operations/service-rates/index.hbs
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
<Layout::Section::Header @title={{t "fleet-ops.operations.service-rates.index.title"}} @searchQuery={{this.query}} @onSearch={{perform this.search}}>
<Button @icon="refresh" @onClick={{this.reload}} @helpText={{t "fleet-ops.operations.service-rates.index.reload-data"}} class="mr-2" />
<FiltersPicker
@columns={{this.columns}}
@onApply={{fn this.filters.apply this}}
@onClear={{fn this.filters.reset this}}
@onFilterClear={{this.filters.clear}}
@onChange={{this.filters.set}}
@buttonWrapperClass="mr-2"
/>
<FiltersPicker @columns={{this.columns}} @onApply={{fn this.filters.apply this}} @onClear={{fn this.filters.reset this}} @onFilterClear={{this.filters.clear}} @onChange={{this.filters.set}} @buttonWrapperClass="mr-2" />
<VisibleColumnPicker @columns={{this.columns}} @onChange={{fn (mut this.columns)}} class="mr-2" />
{{#if (safe-has this.table "selectedRows")}}
<DropdownButton @icon="layer-group" @text={{t "fleet-ops.common.bulk-action"}} @type="magic" @size="sm" @buttonWrapperClass="mr-2" @contentClass="dropdown-menu" as |dd|>
Expand All @@ -21,7 +14,7 @@
</DropdownButton>
{{/if}}
<Button @icon="plus" @iconPrefix="fas" @type="primary" @text={{t "fleet-ops.common.new"}} class="mr-2" @onClick={{transition-to "operations.service-rates.index.new"}} />
<Button @icon="long-arrow-up" @iconClass="rotate-icon-45" @text={{t "fleet-ops.common.export"}} />
<Button @icon="long-arrow-up" @iconClass="rotate-icon-45" @text={{t "fleet-ops.common.export"}} @onClick={{this.exportServiceRates}} />
</Layout::Section::Header>

<Layout::Section::Body>
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fleetbase/fleetops-api",
"version": "0.4.28",
"version": "0.4.29",
"description": "Fleet & Transport Management Extension for Fleetbase",
"keywords": [
"fleetbase-extension",
Expand All @@ -22,7 +22,7 @@
],
"require": {
"php": "^8.0",
"fleetbase/core-api": "^1.4.23",
"fleetbase/core-api": "^1.4.24",
"barryvdh/laravel-dompdf": "^2.0",
"brick/geo": "0.7.2",
"cknow/laravel-money": "^7.1",
Expand Down
2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Fleet-Ops",
"version": "0.4.28",
"version": "0.4.29",
"description": "Fleet & Transport Management Extension for Fleetbase",
"repository": "https://github.com/fleetbase/fleetops",
"license": "MIT",
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fleetbase/fleetops-engine",
"version": "0.4.28",
"version": "0.4.29",
"description": "Fleet & Transport Management Extension for Fleetbase",
"fleetbase": {
"route": "fleet-ops"
Expand Down Expand Up @@ -42,8 +42,8 @@
},
"dependencies": {
"@babel/core": "^7.23.2",
"@fleetbase/ember-core": "^0.2.9",
"@fleetbase/ember-ui": "^0.2.14",
"@fleetbase/ember-core": "^0.2.10",
"@fleetbase/ember-ui": "^0.2.15",
"@fleetbase/fleetops-data": "^0.1.15",
"@fleetbase/leaflet-routing-machine": "^3.2.16",
"@fortawesome/ember-fontawesome": "^0.4.1",
Expand Down
43 changes: 21 additions & 22 deletions pnpm-lock.yaml

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

23 changes: 17 additions & 6 deletions server/src/Exports/ContactExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,31 @@

use Fleetbase\FleetOps\Models\Contact;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;

class ContactExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting
class ContactExport implements FromCollection, WithHeadings, WithMapping, WithColumnFormatting, ShouldAutoSize
{
protected array $selections = [];

public function __construct(array $selections = [])
{
$this->selections = $selections;
}

public function map($contact): array
{
return [
$contact->public_id,
$contact->internal_id,
$contact->name,
$contact->address ? $contact->address->address : null,
$contact->email,
$contact->phone,
Date::dateTimeToExcel($contact->created_at),
$contact->created_at,
];
}

Expand All @@ -33,15 +41,14 @@ public function headings(): array
'Address',
'Email',
'Phone',
'Created',
'Date Created',
];
}

public function columnFormats(): array
{
return [
'E' => NumberFormat::FORMAT_DATE_DDMMYYYY,
'F' => NumberFormat::FORMAT_DATE_DDMMYYYY,
'F' => '+#',
'G' => NumberFormat::FORMAT_DATE_DDMMYYYY,
];
}
Expand All @@ -51,6 +58,10 @@ public function columnFormats(): array
*/
public function collection()
{
if ($this->selections) {
return Contact::where('company_uuid', session('company'))->whereIn('uuid', $this->selections)->get();
}

return Contact::where('company_uuid', session('company'))->get();
}
}
Loading

0 comments on commit de16599

Please sign in to comment.