Skip to content

Commit

Permalink
LITE-28565: Add pricelists to request create wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
riazhski committed Sep 21, 2023
1 parent 515ba17 commit 8ab5b8a
Show file tree
Hide file tree
Showing 10 changed files with 346 additions and 16 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1828,6 +1828,22 @@ button + .c-text-field__append-inner > svg[data-v-b5bb9caa]:first-child {
margin-top: 0;
}

/*!*************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
!*** css ./node_modules/css-loader/dist/cjs.js!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js!./node_modules/stylus-loader/dist/cjs.js!./node_modules/vue-loader/lib/index.js??vue-loader-options!./ui/src/components/CreateDeploymentRequestDialog/PricingTab.vue?vue&type=style&index=0&id=506812c9&lang=stylus& ***!
\*************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
.pricing-tab__title {
font-size: 18px;
font-weight: 500;
line-height: 24px;
margin-bottom: 24px;
}
.pricing-tab__detail {
margin-top: 0;
}
.pricing-tab__pricelist {
max-width: 226px;
}

/*!**************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\
!*** css ./node_modules/css-loader/dist/cjs.js!./node_modules/vue-loader/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js!./node_modules/stylus-loader/dist/cjs.js!./node_modules/vue-loader/lib/index.js??vue-loader-options!./ui/src/components/CreateDeploymentRequestDialog/ProductsTab.vue?vue&type=style&index=0&id=4402e027&lang=stylus& ***!
\**************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion connect_ext_ppr/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono&family=Roboto:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<title>Index</title>
<script defer src="vendors.3c43b45d3e9e7cbf9863.js"></script><script defer src="index.b74401130aa96499b74b.js"></script><link href="index.7f54bf0dcbb9dc626487.css" rel="stylesheet"></head>
<script defer src="vendors.3c43b45d3e9e7cbf9863.js"></script><script defer src="index.ab2a9c611cfbbcb19f36.js"></script><link href="index.ff1a8646fa4bbd4febc0.css" rel="stylesheet"></head>

<body>
<div id="app"></div>
Expand Down
24 changes: 19 additions & 5 deletions ui/src/components/CheckboxTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
)
c-checkbox(
v-if="header.value === 'radio'"
:value="localValue.includes(row[valueProp])",
@input="toggleSelected(row[valueProp])",
:value="isChecked(item)",
@input="toggleSelected(row)",
)
slot(
v-else,
Expand All @@ -44,6 +44,10 @@
</template>

<script>
import {
includes,
} from 'ramda';
import cDataTable from '~components/cDataTable.vue';
import cCheckbox from '~components/cCheckbox.vue';
import cSearch from '~components/cSearch.vue';
Expand Down Expand Up @@ -91,6 +95,7 @@ export default {
},
search: String,
returnObject: Boolean,
},
data: () => ({
Expand Down Expand Up @@ -118,21 +123,30 @@ export default {
},
methods: {
isChecked(item) {
return this.returnObject
? includes(item, this.localValue)
: includes(item[this.valueProp], this.localValue);
},
toggleSelected(value) {
const index = this.localValue.indexOf(value);
const currentValue = (this.returnObject) ? value : value[this.valueProp];
const index = this.localValue.indexOf(currentValue);
if (index > -1) {
this.localValue.splice(index, 1);
} else {
this.localValue.push(value);
this.localValue.push(currentValue);
}
},
},
watch: {
isAllSelected(v) {
if (v) {
this.localValue = this.items.map(item => item[this.valueProp]);
this.localValue = (this.returnObject)
? this.items : this.items.map(item => item[this.valueProp]);
} else {
this.localValue = [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ checkbox-table.marketplaces-tab(
:is-all-selected.sync="isAllSelected",
title="Select Marketplaces",
include-all,
return-object,
)
template(#marketplace="{ row }")
detail-item.hub-tab__detail
Expand Down Expand Up @@ -117,7 +118,7 @@ export default {
deep: true,
immediate: true,
handler(val) {
this.$set(this.localValue, 'choices', val.map(id => ({ id })));
this.$set(this.localValue, 'choices', val);
},
},
Expand Down
200 changes: 200 additions & 0 deletions ui/src/components/CreateDeploymentRequestDialog/PricingTab.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
<template lang="pug">
.pricing-tab
p.pricing-tab__title Link Pricing Stream Batches to Marketplaces

c-data-table.pricing-tab__table(
:value="marketplacesWithPriceLists",
:headers="headers",
:prepare-row="prepareRow",
:updating="loading",
hide-all-pagination-sections,
fix-layout,
)
template(#items="{ row, visibleHeaders }")
tr.table__row.hoverable
td(
v-for="header in visibleHeaders"
:key="header.value",
)
template(v-if="header.value === 'marketplace'")
detail-item.pricing-tab__detail
template(#image="")
pic.object-image(
:src="row.icon",
:width="32",
:height="32",
size="contain",
)
template(#body-text="")
.truncate-text
span {{ row.name }}
template(#assistive-text="")
span {{ row.id }}

template(v-else-if="header.value === 'pricing'")

c-menu(
v-if="row.pricelist",
locator="batches-list",
outline,
small,
:min-width="266",
)
template(#trigger="")
c-button.c-menu-list__open(
locator="c-menu-list_open-button",
small,
:upperCase="false",
:icon-right="icons.googleArrowDropDownBaseline"
mode="outlined",
)
.truncate-text.pricing-tab__pricelist(
:title="row.pricelist.name",
) {{ row.pricelist.name }}

template(#default="")
div(
v-for="batch in row.batches",
:key="batch.id",
)
c-button(
small,
:upper-case="false",
@click="setBatch(batch, row)",
)
.truncate-text {{ batch.name }}

.assistive-color(v-else)
</template>

<script>
import {
googleArrowDropDownBaseline,
} from '@cloudblueconnect/material-svg/baseline';
import {
filter,
findIndex,
map,
pathEq,
pick,
propEq,
} from 'ramda';
import cButton from '~components/cButton.vue';
import cDataTable from '~components/cDataTable.vue';
import cMenu from '~components/cMenu.vue';
import DetailItem from '~components/DetailItem.vue';
import Pic from '~components/Pic.vue';
import sync from '~mixins/sync';
import {
getDeploymentBatches,
} from '@/utils';
export default {
mixins: [sync([{ prop: 'value', local: 'localValue' }])],
components: {
cButton,
cDataTable,
cMenu,
DetailItem,
Pic,
},
props: {
value: {
type: Array,
default: () => [],
},
marketplaces: {
type: Array,
required: true,
},
deploymentId: String,
},
data: () => ({
localValue: [],
marketplacesWithPriceLists: [],
loading: false,
icons: {
googleArrowDropDownBaseline,
},
headers: [
{
text: 'Marketplace',
value: 'marketplace',
align: 'left',
},
{
text: 'Pricing stream batch',
value: 'pricing',
align: 'left',
width: 266,
},
],
}),
methods: {
prepareRow(item) {
return {
id: item.id,
name: item.name,
icon: item.icon,
batches: item.batches,
pricelist: item.batches[0],
};
},
setBatch(batch, marketplace) {
const index = findIndex(propEq(marketplace.id, 'id'), this.localValue);
this.localValue[index].pricelist = pick(['id', 'name'], batch);
},
},
async created() {
this.localValue = this.marketplaces;
try {
this.loading = true;
const batchesList = await getDeploymentBatches(this.deploymentId);
const getBatchesForMarketplace = item => ({
...item,
batches: filter(pathEq(item.id, ['stream', 'context', 'marketplace', 'id']))(batchesList),
});
this.marketplacesWithPriceLists = map(getBatchesForMarketplace, this.marketplaces);
} catch (e) {
this.$emit('error', e);
} finally {
this.loading = false;
}
},
};
</script>

<style lang="stylus">
.pricing-tab {
&__title {
font-size: 18px;
font-weight: 500;
line-height: 24px;
margin-bottom: 24px;
}
&__detail {
margin-top: 0;
}
&__pricelist {
max-width: 226px;
}
}
</style>
22 changes: 21 additions & 1 deletion ui/src/components/CreateDeploymentRequestDialog/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ c-dialog(
template(#options="")
options-tab(v-model="form.options")

template(#pricing="")
pricing-tab(
v-model="form.pricing",
:deployment-id="localDeployment?.id",
:marketplaces="form.marketplaces.choices",
@error="setError",
)

template(#summary="")
summary-tab(
:request-id="createdRequest?.id",
Expand All @@ -55,10 +63,16 @@ c-dialog(
</template>

<script>
import {
map,
pick,
} from 'ramda';
import cDialog from '~components/cDialog.vue';
import HubsTab from './HubsTab.vue';
import MarketplacesTab from './MarketplacesTab.vue';
import OptionsTab from './OptionsTab.vue';
import PricingTab from './PricingTab.vue';
import ProductsTab from './ProductsTab.vue';
import PprTab from './PprTab.vue';
import SummaryTab from './SummaryTab.vue';
Expand All @@ -79,6 +93,7 @@ const defaultForm = () => ({
choices: [],
all: false,
},
pricing: [],
options: {
manual: false,
delegate: false,
Expand All @@ -93,6 +108,7 @@ export default {
HubsTab,
MarketplacesTab,
OptionsTab,
PricingTab,
ProductsTab,
PprTab,
SummaryTab,
Expand Down Expand Up @@ -141,6 +157,10 @@ export default {
key: 'options',
label: 'Options',
},
{
key: 'pricing',
label: 'Pricing',
},
{
key: 'summary',
label: 'Summary',
Expand Down Expand Up @@ -228,7 +248,7 @@ export default {
async createDeploymentRequest() {
this.createdRequest = await createDeploymentRequest({
marketplaces: this.form.marketplaces.choices,
marketplaces: map(pick(['id', 'pricelist']), this.form.marketplaces.choices),
deployment: { id: this.localDeployment.id },
ppr: { id: this.form.ppr.id },
manually: this.form.options.manual,
Expand Down
2 changes: 2 additions & 0 deletions ui/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export const getProductHubs = (productId) => rest.get(`/api/products/${productId

export const getDeploymentMarketplaces = (deploymentId) => rest.get(`/api/deployments/${deploymentId}/marketplaces`);

export const getDeploymentBatches = (deploymentId) => rest.get(`/api/deployments/${deploymentId}/pricing/batches`);

export const getDeploymentRequestMarketplaces = (requestId) => rest.get(`/api/deployments/requests/${requestId}/marketplaces`);

export const getDeploymentRequestTasks = (requestId) => rest.get(`/api/deployments/requests/${requestId}/tasks`);
Expand Down

0 comments on commit 8ab5b8a

Please sign in to comment.