@live-change/balance-frontend 0.8.84 → 0.8.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,8 +2,14 @@
2
2
  <div class="w-full">
3
3
  <div class="surface-card shadow-1 border-round p-3 mb-1">
4
4
  <div class="text-xl">Balance: {{ balance.owner }}</div>
5
- <div>Amount: {{ balance.amount }}</div>
6
- <div>Available: {{ balance.available }}</div>
5
+ <div>
6
+ Amount:
7
+ <BalanceDisplay :available="false" ownerType="balanceTest_balance" :owner="name" />
8
+ </div>
9
+ <div>
10
+ Available:
11
+ <BalanceDisplay :available="true" ownerType="balanceTest_balance" :owner="name" />
12
+ </div>
7
13
  </div>
8
14
  <div class="surface-card shadow-1 border-round p-3 text-xl mb-1 mt-2 text-xl">
9
15
  Operations:
@@ -21,7 +27,7 @@
21
27
  </div>
22
28
  <div class="w-10rem text-right pl-3 font-semibold mr-3"
23
29
  :class="operation.change > 0 ? 'text-green-500' : 'text-red-500'">
24
- {{ operation.change > 0 ? '+' : '-' }} {{ Math.abs(operation.change) }}
30
+ {{ operation.change > 0 ? '+' : '-' }} <CurrencyDisplay :value="Math.abs(+operation.change)" />
25
31
  </div>
26
32
  <Button label="Finish" icon="pi pi-check" severity="success"
27
33
  @click="actions.balanceTest.finishOperation({ balance: balance.id, operation: operation.id })" />
@@ -44,7 +50,9 @@
44
50
  <InputText id="name" type="text" class="w-full"
45
51
  aria-describedby="email-help" :class="{ 'p-invalid': data.nameError }"
46
52
  v-model="data.name" />
47
- <small id="email-help" class="p-error">{{ t(`errors.${data.nameError}`) }}</small>
53
+ <small v-if="data.nameError" id="email-help" class="p-error">
54
+ {{ t(`errors.${data.nameError}`) }}
55
+ </small>
48
56
  </div>
49
57
  </div>
50
58
  <div class="col-12 md:col-6 py-1">
@@ -55,7 +63,9 @@
55
63
  <InputNumber id="name" type="text" class="w-full" :min="-1000000" :max="1000000" showButtons :step="1000"
56
64
  aria-describedby="email-help" :class="{ 'p-invalid': data.changeError }"
57
65
  v-model="data.change" />
58
- <small id="email-help" class="p-error">{{ t(`errors.${data.changeError}`) }}</small>
66
+ <small v-if="data.changeError" id="email-help" class="p-error">
67
+ {{ t(`errors.${data.changeError}`) }}
68
+ </small>
59
69
  </div>
60
70
  </div>
61
71
  <Button label="Start operation" icon="pi pi-plus" type="submit" />
@@ -96,7 +106,9 @@
96
106
  <div class="surface-card shadow-1 border-round p-3 text-xl mb-1 mt-2 text-xl">
97
107
  Finished operations:
98
108
  </div>
99
- <div v-if="finishedOperations.length === 0" class="surface-card shadow-1 border-round p-3 mb-1">
109
+ <OperationsList ownerType="balanceTest_balance" :owner="name" state="finished" />
110
+
111
+ <!-- <div v-if="finishedOperations.length === 0" class="surface-card shadow-1 border-round p-3 mb-1">
100
112
  No operations finished
101
113
  </div>
102
114
  <div v-for="operation of finishedOperations"
@@ -114,7 +126,7 @@
114
126
  <div class="w-10rem text-right pl-3 font-semibold mr-3">
115
127
  {{ operation.amountAfter }}
116
128
  </div>
117
- </div>
129
+ </div>-->
118
130
 
119
131
  </div>
120
132
  </template>
@@ -122,6 +134,9 @@
122
134
  <script setup>
123
135
 
124
136
  import InputText from "primevue/inputtext"
137
+ import BalanceDisplay from './components/BalanceDisplay.vue'
138
+ import OperationsList from './components/OperationsList.vue'
139
+ import CurrencyDisplay from './components/CurrencyDisplay.vue'
125
140
 
126
141
  import {
127
142
  defineProps, defineEmits, defineModel, toRefs, computed, watch, ref, watchEffect, onUnmounted,
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <CurrencyDisplay
3
- value="value"
3
+ :value="value"
4
4
  :currency="currency"
5
5
  :denomination="denomination"
6
6
  :i18nConfig="i18nConfig"
@@ -11,7 +11,7 @@
11
11
  import { defineProps, toRefs, computed, inject } from 'vue'
12
12
  import DefaultCurrencyDisplay from './CurrencyDisplay.vue'
13
13
 
14
- import { injectComponent } from '@live-change/vue3-ssr'
14
+ import { injectComponent } from '@live-change/vue3-components'
15
15
  const CurrencyDisplay = injectComponent({
16
16
  name: 'CurrencyDisplay',
17
17
  type: 'currency'
@@ -36,11 +36,11 @@
36
36
  },
37
37
  i18nConfig: {
38
38
  type: Object,
39
- default: undefined
39
+ default: () => undefined
40
40
  },
41
41
  i18nDefaultConfig: {
42
42
  type: Object,
43
- default: () => {}
43
+ default: () => undefined
44
44
  },
45
45
  available: {
46
46
  type: Boolean,
@@ -8,7 +8,6 @@
8
8
 
9
9
  const props = defineProps({
10
10
  value: {
11
- type: Number,
12
11
  required: true
13
12
  },
14
13
  currency: {
@@ -25,12 +24,13 @@
25
24
  },
26
25
  i18nDefaultConfig: {
27
26
  type: Object,
28
- default: () => {}
27
+ default: () => ({ maximumFractionDigits: 2, notation: 'standard' })
29
28
  }
30
29
  })
31
30
  const { value, currency, denomination, i18nConfig, i18nDefaultConfig } = toRefs(props)
32
31
 
33
- import { n } from 'vue-i18n'
32
+ import { useI18n } from 'vue-i18n'
33
+ const { n } = useI18n()
34
34
 
35
35
  const currencyConfig = inject('currencyI18nConfig:'+currency, null)
36
36
  const defaultConfig = inject('currencyI18nConfig', null)
@@ -38,9 +38,10 @@
38
38
  const config = computed(() => i18nConfig ?? currencyConfig ?? defaultConfig ?? i18nDefaultConfig)
39
39
 
40
40
  const formatted = computed(() => {
41
+ console.log('CurrencyDisplay', value.value, denomination.value, +value.value / +(denomination.value || config.value.denomination || 100))
41
42
  return n(
42
- value.value / (denomination.value ?? config.value.denomination ?? 100),
43
- currency.value ?? config.value.currency ?? 'USD',
43
+ +value.value / +(denomination.value || config.value.denomination || 100),
44
+ currency.value ?? config.value.currency ?? 'usd',
44
45
  config.value
45
46
  )
46
47
  })
@@ -1,9 +1,77 @@
1
1
  <template>
2
-
2
+ <RangeViewer :key="operationsKey" :pathFunction="operationsPathFunction"
3
+ :canLoadTop="false" :canDropTop="false"
4
+ :canLoadBottom="true" :canDropBottom="false"
5
+ loadTopSensorSize="1500px" loadBottomSensorSize="1500px"
6
+ dropTopSensorSize="1000px" dropBottomSensorSize="1000px">
7
+ <template #empty>
8
+ <div class="text-xl text-800 my-3 mx-3">
9
+ No operations done yet...
10
+ </div>
11
+ </template>
12
+ <template #default="{ item: operation }">
13
+ <div class="surface-card shadow-1 border-round mb-1 flex flex-row align-items-center">
14
+ <div class="flex-1 flex-grow pl-3 py-1">
15
+ <slot name="operationCause">
16
+ <pre>{{ operation.cause }}</pre>
17
+ </slot>
18
+ </div>
19
+ <time class="w-15rem text-right pl-3 font-semibold mr-3"
20
+ :datetime="operation.updatedAt ?? operation.createdAt">
21
+ {{ d(operation.updatedAt ?? operation.createdAt, 'shortTime') }}
22
+ </time>
23
+ <div class="w-10rem text-right pl-3 font-semibold mr-3"
24
+ :class="operation.change > 0 ? 'text-green-500' : 'text-red-500'">
25
+ {{ operation.change > 0 ? '+' : '-' }} <CurrencyDisplay :value="Math.abs(operation.change)" />
26
+ </div>
27
+ <div class="w-10rem text-right pl-3 font-semibold mr-3">
28
+ <CurrencyDisplay :value="operation.amountAfter" />
29
+ </div>
30
+ </div>
31
+ </template>
32
+ </RangeViewer>
3
33
  </template>
4
34
 
5
35
  <script setup>
6
36
 
37
+ import { RangeViewer } from "@live-change/vue3-components"
38
+
39
+ import { defineProps, toRefs, computed } from 'vue'
40
+
41
+ const props = defineProps({
42
+ ownerType: {
43
+ type: String,
44
+ required: true
45
+ },
46
+ owner: {
47
+ type: String,
48
+ required: true
49
+ },
50
+ state: {
51
+ type: String,
52
+ default: null
53
+ }
54
+ })
55
+ const { ownerType, owner, state } = toRefs(props)
56
+
57
+ import { usePath, live, reverseRange } from '@live-change/vue3-ssr'
58
+ const path = usePath()
59
+
60
+ import { useI18n } from 'vue-i18n'
61
+ import CurrencyDisplay from './CurrencyDisplay.vue'
62
+ const { d, n } = useI18n()
63
+
64
+ function operationsPathFunction(range) {
65
+ return path.balance.operationsByBalance({
66
+ ...reverseRange(range),
67
+ balance: `${JSON.stringify(ownerType.value)}:${JSON.stringify(owner.value)}`,
68
+ state: state.value
69
+ })
70
+ }
71
+
72
+ const operationsKey = computed(() => `${ownerType.value}:${owner.value}:${state.value}`)
73
+
74
+
7
75
  </script>
8
76
 
9
77
  <style scoped>
@@ -41,7 +41,7 @@ export function createRouter(app, config) {
41
41
  // import.meta.env.SSR is injected by Vite.
42
42
  history: import.meta.env.SSR ? createMemoryHistory() : createWebHistory(),
43
43
  routes: [
44
- ...userRoutes({ ...config, prefix: prefix + 'user/' }),
44
+ ...userRoutes({ ...config, prefix: '/user/' }),
45
45
 
46
46
  ...balanceRoutes(config),
47
47
 
package/index.js CHANGED
@@ -1,2 +1,5 @@
1
1
 
2
- export { }
2
+ import BalanceDisplay from './front/src/components/BalanceDisplay.vue'
3
+ import CurrencyDisplay from './front/src/components/CurrencyDisplay.vue'
4
+
5
+ export { BalanceDisplay, CurrencyDisplay}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/balance-frontend",
3
- "version": "0.8.84",
3
+ "version": "0.8.85",
4
4
  "scripts": {
5
5
  "memDev": "node server/start.js memDev --enableSessions --initScript ./init.js --dbAccess",
6
6
  "localDevInit": "rm tmp.db; node server/start.js localDev --enableSessions --initScript ./init.js",
@@ -35,41 +35,41 @@
35
35
  "@codemirror/language": "6.10.1",
36
36
  "@dotenvx/dotenvx": "0.27.0",
37
37
  "@fortawesome/fontawesome-free": "^6.5.2",
38
- "@live-change/access-control-frontend": "^0.8.84",
39
- "@live-change/access-control-service": "^0.8.84",
40
- "@live-change/backup-service": "^0.8.84",
41
- "@live-change/blog-frontend": "^0.8.84",
42
- "@live-change/blog-service": "^0.8.84",
43
- "@live-change/cli": "^0.8.84",
44
- "@live-change/content-frontend": "^0.8.84",
45
- "@live-change/content-service": "^0.8.84",
46
- "@live-change/dao": "^0.8.84",
47
- "@live-change/dao-vue3": "^0.8.84",
48
- "@live-change/dao-websocket": "^0.8.84",
49
- "@live-change/db-client": "^0.8.84",
50
- "@live-change/email-service": "^0.8.84",
51
- "@live-change/framework": "^0.8.84",
52
- "@live-change/frontend-auto-form": "^0.8.84",
53
- "@live-change/frontend-base": "^0.8.84",
54
- "@live-change/geoip-service": "^0.8.84",
55
- "@live-change/image-frontend": "^0.8.84",
56
- "@live-change/locale-settings-service": "^0.8.84",
57
- "@live-change/password-authentication-service": "^0.8.84",
58
- "@live-change/prosemirror-service": "^0.8.84",
59
- "@live-change/secret-code-service": "^0.8.84",
60
- "@live-change/secret-link-service": "^0.8.84",
61
- "@live-change/session-service": "^0.8.84",
62
- "@live-change/task-service": "^0.8.84",
63
- "@live-change/upload-frontend": "^0.8.84",
64
- "@live-change/url-frontend": "^0.8.84",
65
- "@live-change/url-service": "^0.8.84",
66
- "@live-change/user-frontend": "^0.8.84",
67
- "@live-change/user-identification-service": "^0.8.84",
68
- "@live-change/user-service": "^0.8.84",
69
- "@live-change/vote-service": "^0.8.84",
70
- "@live-change/vue3-components": "^0.8.84",
71
- "@live-change/vue3-ssr": "^0.8.84",
72
- "@live-change/wysiwyg-frontend": "^0.8.84",
38
+ "@live-change/access-control-frontend": "^0.8.85",
39
+ "@live-change/access-control-service": "^0.8.85",
40
+ "@live-change/backup-service": "^0.8.85",
41
+ "@live-change/blog-frontend": "^0.8.85",
42
+ "@live-change/blog-service": "^0.8.85",
43
+ "@live-change/cli": "^0.8.85",
44
+ "@live-change/content-frontend": "^0.8.85",
45
+ "@live-change/content-service": "^0.8.85",
46
+ "@live-change/dao": "^0.8.85",
47
+ "@live-change/dao-vue3": "^0.8.85",
48
+ "@live-change/dao-websocket": "^0.8.85",
49
+ "@live-change/db-client": "^0.8.85",
50
+ "@live-change/email-service": "^0.8.85",
51
+ "@live-change/framework": "^0.8.85",
52
+ "@live-change/frontend-auto-form": "^0.8.85",
53
+ "@live-change/frontend-base": "^0.8.85",
54
+ "@live-change/geoip-service": "^0.8.85",
55
+ "@live-change/image-frontend": "^0.8.85",
56
+ "@live-change/locale-settings-service": "^0.8.85",
57
+ "@live-change/password-authentication-service": "^0.8.85",
58
+ "@live-change/prosemirror-service": "^0.8.85",
59
+ "@live-change/secret-code-service": "^0.8.85",
60
+ "@live-change/secret-link-service": "^0.8.85",
61
+ "@live-change/session-service": "^0.8.85",
62
+ "@live-change/task-service": "^0.8.85",
63
+ "@live-change/upload-frontend": "^0.8.85",
64
+ "@live-change/url-frontend": "^0.8.85",
65
+ "@live-change/url-service": "^0.8.85",
66
+ "@live-change/user-frontend": "^0.8.85",
67
+ "@live-change/user-identification-service": "^0.8.85",
68
+ "@live-change/user-service": "^0.8.85",
69
+ "@live-change/vote-service": "^0.8.85",
70
+ "@live-change/vue3-components": "^0.8.85",
71
+ "@live-change/vue3-ssr": "^0.8.85",
72
+ "@live-change/wysiwyg-frontend": "^0.8.85",
73
73
  "@vueuse/core": "^10.11.0",
74
74
  "codeceptjs-assert": "^0.0.5",
75
75
  "compression": "^1.7.4",
@@ -91,7 +91,7 @@
91
91
  "vue3-scroll-border": "0.1.6"
92
92
  },
93
93
  "devDependencies": {
94
- "@live-change/codeceptjs-helper": "^0.8.84",
94
+ "@live-change/codeceptjs-helper": "^0.8.85",
95
95
  "codeceptjs": "^3.6.5",
96
96
  "generate-password": "1.7.1",
97
97
  "playwright": "^1.41.2",
@@ -102,5 +102,5 @@
102
102
  "author": "Michał Łaszczewski <michal@laszczewski.pl>",
103
103
  "license": "ISC",
104
104
  "description": "",
105
- "gitHead": "53f9ddc7529c28f12cb77c4a2758b553461e46b6"
105
+ "gitHead": "1f07885a23183da611b39c2e729b4e704cdcd0ee"
106
106
  }