Skip to content

Commit 52da957

Browse files
committed
wip
1 parent 691a7a6 commit 52da957

File tree

5 files changed

+57
-91
lines changed

5 files changed

+57
-91
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<template>
2+
<div>
3+
<!-- <div class="flex flex-wrap">-->
4+
<!-- <div-->
5+
<!-- v-for="(item, i) in items"-->
6+
<!-- :key="item.id"-->
7+
<!-- class="relationship-index-field-item h-5"-->
8+
<!-- :class="{ 'mb-1.5': i < items.length-1 }"-->
9+
<!-- >-->
10+
<!-- <div class="flex items-center shrink">-->
11+
<!-- <div v-if="item.hasOwnProperty('published') && item.published !== null"-->
12+
<!-- class="little-dot h-1 w-1 rtl:ml-1 ltr:mr-1" :class="[item.published ? 'bg-green-600' : 'bg-gray-400 dark:bg-dark-200']" />-->
13+
<!-- <a :href="item.edit_url" :title="item.title" v-text="item.title" />-->
14+
<!-- </div>-->
15+
<!-- </div>-->
16+
<!-- </div>-->
17+
<!-- <button v-if="hasMore && ! showingAll" @click.stop="showAll" class="mt-1 text-blue text-2xs" v-text="__('messages.view_more_count', {count: value.length - 2})" />-->
18+
<!-- <button v-if="showingAll" @click.stop="hideExtra" class="mt-1 text-blue text-2xs" v-text="__('Hide')" />-->
19+
20+
<div class="flex items-center">
21+
<div class="flex-1">
22+
<div class="truncate">
23+
<a v-if="value.type === 'user' && value.viewable" :href="value.edit_url" class="truncate v-popper--has-tooltip">
24+
{{ value.name }}
25+
</a>
26+
<div v-else-if="value.type === 'guest'" class="truncate v-popper--has-tooltip">
27+
{{ value.name }}
28+
<div class="status-index-field select-none status-draft ml-2">Guest</div>
29+
</div>
30+
<div v-else v-text="value.name" />
31+
</div>
32+
</div>
33+
</div>
34+
</div>
35+
</template>
36+
37+
<script>
38+
export default {
39+
mixins: [IndexFieldtype],
40+
}
41+
</script>

resources/js/components/Inputs/RegionSelector.vue

-75
This file was deleted.

resources/js/cp.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import OrderReceiptFieldtype from './components/Fieldtypes/OrderReceiptFieldtype
33
import MoneyFieldtype from './components/Fieldtypes/MoneyFieldtype.vue'
44
import ProductVariantsFieldtype from './components/Fieldtypes/ProductVariants/ProductVariantsFieldtype.vue'
55
import CustomerFieldtype from './components/Fieldtypes/CustomerFieldtype.vue'
6+
import CustomerFieldtypeIndex from './components/Fieldtypes/CustomerFieldtypeIndex.vue'
67

78
Statamic.$components.register('order_receipt-fieldtype', OrderReceiptFieldtype)
89
Statamic.$components.register('money-fieldtype', MoneyFieldtype)
@@ -11,10 +12,7 @@ Statamic.$components.register(
1112
ProductVariantsFieldtype
1213
)
1314
Statamic.$components.register('customer-fieldtype', CustomerFieldtype)
14-
15-
// Inputs
16-
import RegionSelector from './components/Inputs/RegionSelector.vue'
17-
Statamic.$components.register('region-selector', RegionSelector)
15+
Statamic.$components.register('customer-fieldtype-index', CustomerFieldtypeIndex)
1816

1917
// Listings
2018
import CouponListing from './components/Listings/CouponListing.vue'

src/Fieldtypes/CustomerFieldtype.php

+14-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace DuncanMcClean\SimpleCommerce\Fieldtypes;
44

55
use DuncanMcClean\SimpleCommerce\Customers\GuestCustomer;
6-
use Statamic\Facades\Blueprint;
76
use Statamic\Facades\User;
87
use Statamic\Fields\Field;
98
use Statamic\Fields\Fieldtype;
@@ -56,4 +55,18 @@ public function preProcess($data)
5655
'edit_url' => $data->editUrl(),
5756
];
5857
}
58+
59+
public function preProcessIndex($data)
60+
{
61+
return $this->preProcess($data);
62+
}
63+
64+
public function augment($value)
65+
{
66+
if (! $value) {
67+
return;
68+
}
69+
70+
return $value;
71+
}
5972
}

src/Orders/AugmentedOrder.php

-11
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,4 @@ private function commonKeys(): array
3333
}
3434

3535
// todo: status
36-
37-
public function customer()
38-
{
39-
$customer = $this->data->customer();
40-
41-
if ($customer instanceof GuestCustomer) {
42-
return $customer->toArray();
43-
}
44-
45-
return $customer?->toAugmentedCollection();
46-
}
4736
}

0 commit comments

Comments
 (0)