Skip to content

Commit

Permalink
Implemented: support to copy the order identification when clicked on…
Browse files Browse the repository at this point in the history
… order identification chip(#175)
  • Loading branch information
ymaheshwari1 committed Jul 12, 2023
1 parent 7b207b8 commit 89ca0b4
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ const i18n = createI18n({

// TODO Check if this is needed in updated versions
// Currently this method is added to be used in ts files
const translate = (key: string) => {
const translate = (key: string, named?: any) => {
if (!key) {
return '';
}
return i18n.global.t(key);
return i18n.global.t(key, named);
};

export { i18n as default, translate }
2 changes: 2 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"Completed": "Completed",
"Configuration Missing": "Configuration Missing",
"Confirm": "Confirm",
"Copied": "Copied { value }",
"Custom Label": "Custom Label",
"Customer letter": "Customer letter",
"Damaged": "Damaged",
Expand Down Expand Up @@ -50,6 +51,7 @@
"Import shipped order details from an external system based on tracking codes. Orders that have tracking codes will automatically be shipped at the end of the day.": "Import shipped order details from an external system based on tracking codes. Orders that have tracking codes will automatically be shipped at the end of the day.",
"Import shipped orders": "Import shipped orders",
"In Progress": "In Progress",
"Internal Id copied to clipboard": "Internal Id copied to clipboard",
"Last brokered": "Last brokered",
"Loading": "Loading",
"Login": "Login",
Expand Down
2 changes: 2 additions & 0 deletions src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"Completed": "Completado",
"Configuration Missing": "Configuration Missing",
"Confirm": "Confirm",
"Copied": "Copied { value }",
"Custom Label": "Custom Label",
"Customer letter": "Customer letter",
"Damaged": "Damaged",
Expand Down Expand Up @@ -50,6 +51,7 @@
"Import shipped order details from an external system based on tracking codes. Orders that have tracking codes will automatically be shipped at the end of the day.": "Import shipped order details from an external system based on tracking codes. Orders that have tracking codes will automatically be shipped at the end of the day.",
"Import shipped orders": "Import shipped orders",
"In Progress": "En curso",
"Internal Id copied to clipboard": "Internal Id copied to clipboard",
"Last brokered": "Última intermediación",
"Loading": "Loading",
"Login": "Acceso",
Expand Down
14 changes: 13 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { translate } from '@/i18n';
import store from '@/store';
import { JsonToCsvOption } from '@/types';
import { Plugins } from '@capacitor/core';
import { toastController } from '@ionic/vue';
import { saveAs } from 'file-saver';
import { DateTime } from 'luxon';
Expand Down Expand Up @@ -89,4 +91,14 @@ const jsonToCsv = (file: any, options: JsonToCsvOption = {}) => {
return blob;
}

export { formatDate, formatUtcDate, getFeature, handleDateTimeInput, showToast, hasError, parseCsv, jsonToCsv}
const copyToClipboard = async (value: string, text?: string) => {
const { Clipboard } = Plugins;

await Clipboard.write({
string: value,
}).then(() => {
text ? showToast(translate(text)) : showToast(translate("Copied", { value }));
});
}

export { copyToClipboard, formatDate, formatUtcDate, getFeature, handleDateTimeInput, showToast, hasError, parseCsv, jsonToCsv}
5 changes: 3 additions & 2 deletions src/views/Completed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</div>

<div class="order-tags">
<ion-chip outline>
<ion-chip @click="copyToClipboard(order.orderId, 'Internal Id copied to clipboard')" outline>
<ion-icon :icon="pricetagOutline" />
<ion-label>{{ order.orderId }}</ion-label>
</ion-chip>
Expand Down Expand Up @@ -157,7 +157,7 @@ import { printOutline, downloadOutline, pricetagOutline, ellipsisVerticalOutline
import Popover from '@/views/ShippingPopover.vue'
import { useRouter } from 'vue-router';
import { mapGetters, useStore } from 'vuex'
import { formatUtcDate, getFeature, showToast } from '@/utils'
import { copyToClipboard, formatUtcDate, getFeature, showToast } from '@/utils'
import { hasError } from '@/adapter'
import Image from '@/components/Image.vue'
import { UtilService } from '@/services/UtilService';
Expand Down Expand Up @@ -552,6 +552,7 @@ export default defineComponent({
const router = useRouter();
return {
copyToClipboard,
checkmarkDoneOutline,
downloadOutline,
ellipsisVerticalOutline,
Expand Down
5 changes: 3 additions & 2 deletions src/views/InProgress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</div>

<div class="order-tags">
<ion-chip outline>
<ion-chip @click="copyToClipboard(order.orderId, 'Internal Id copied to clipboard')" outline>
<ion-icon :icon="pricetagOutline" />
<ion-label>{{ order.orderId }}</ion-label>
</ion-chip>
Expand Down Expand Up @@ -191,7 +191,7 @@ import { defineComponent } from 'vue';
import { printOutline, addOutline, ellipsisVerticalOutline, checkmarkDoneOutline, pricetagOutline, optionsOutline } from 'ionicons/icons'
import Popover from "@/views/PackagingPopover.vue";
import { mapGetters, useStore } from 'vuex';
import { formatUtcDate, getFeature, showToast } from '@/utils';
import { copyToClipboard, formatUtcDate, getFeature, showToast } from '@/utils';
import { hasError } from '@/adapter';
import Image from '@/components/Image.vue'
import ViewSizeSelector from '@/components/ViewSizeSelector.vue';
Expand Down Expand Up @@ -773,6 +773,7 @@ export default defineComponent({
const store = useStore();
return {
copyToClipboard,
addOutline,
printOutline,
ellipsisVerticalOutline,
Expand Down
5 changes: 3 additions & 2 deletions src/views/OpenOrders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</div>

<div class="order-tags">
<ion-chip outline>
<ion-chip @click="copyToClipboard(orders.doclist.docs[0].orderId, 'Internal Id copied to clipboard')" outline>
<ion-icon :icon="pricetagOutline" />
<ion-label>{{ orders.doclist.docs[0].orderId }}</ion-label>
</ion-chip>
Expand Down Expand Up @@ -129,7 +129,7 @@ import { optionsOutline, pricetagOutline, printOutline, refreshCircleOutline } f
import AssignPickerModal from '@/views/AssignPickerModal.vue';
import { mapGetters, useStore } from 'vuex';
import Image from '@/components/Image.vue'
import { formatUtcDate, getFeature } from '@/utils'
import { copyToClipboard, formatUtcDate, getFeature } from '@/utils'
import { hasError } from '@/adapter';
import { UtilService } from '@/services/UtilService';
import { prepareOrderQuery } from '@/utils/solrHelper';
Expand Down Expand Up @@ -288,6 +288,7 @@ export default defineComponent({
const store = useStore();
return{
copyToClipboard,
formatUtcDate,
getFeature,
optionsOutline,
Expand Down

0 comments on commit 89ca0b4

Please sign in to comment.