Conditional Rendering with Vue and Prime Vue Library - node.js

I have a diagram that is composed of inputs and outputs. Using Primevue I am rendering a table with data for the inputs or outputs. However inputs and outputs should render different columns (not simultaneously it either displays input data or out put data)
I am wondering how I can render different columns on the table depending on what the API is returning. Instead of having to create two different tables. Is it possible to have a ternary operator in the ?
Here is a sample of the table component:
<DataTable
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown"
:value="cardListData[0]"
:loading="isLoading"
:sortOrder="-1"
:paginator="true"
v-model:filters="filters"
:rows="rowsPerPage"
:rowsPerPageOptions="[10, 20, 50]"
responsiveLayout="stack"
:globalFilterFields="['date', 'lotNumber']"
>
<template #header>
<div class="flex justify-content-between">
<Button
type="button"
icon="pi pi-filter-slash"
:label="$t('Clear')"
class="p-button-outlined"
#click="clearFilter()"
/>
<span class="p-input-icon-left">
<i class="pi pi-search" />
<InputText v-model="filters['global'].value" :placeholder="$t('Keyword Search')" />
</span>
</div>
</template>
<template #empty> {{ $t('No data found')}}. </template>
<template #loading> {{ $t('Loading data. Please wait')}}. </template>
<Column field="date" :header="$t('Date')" :sortable="true">
<template #body="slotProps">
<div class="detail">
{{ slotProps.data.date ? formatDate(slotProps.data.date): 'N/A' }}
</div>
</template>
</Column>
<Column field="name" :header="$t('Name')" :sortable="true">
<template #body="slotProps">
<div class="detail">
{{ slotProps.data.name ? slotProps.data.name: 'N/A' }}
</div>
</template>
</Column>
<Column field="provider" :header="$t('Supplier')" :sortable="true">
<template #body="slotProps">
<div class="detail">
{{ slotProps.data.provider ? slotProps.data.provider: 'N/A' }}
</div>
</template>
</Column>
<Column field="quantity" :header="$t('Quantity')" :sortable="true">
<template #body="slotProps">
<div class="detail">
{{ slotProps.data.quantity ? slotProps.data.quantity +' g' : 'No Value' }}
</div>
</template>
</Column>
<Column field="type" :header="$t('Type')" :sortable="true">
<template #body="slotProps">
<div class="detail">
{{ slotProps.data.type ? slotProps.data.type : 'No Value' }}
</div>
</template>
</Column>
</DataTable>

Sure, you can use conditional rendering on <Column> like this:
<Column v-if="yourCondition">...</Column>
<Column v-else>...</Column>

Related

Tailwind - css - flex placement

I have a footer with some list items and then some social media icons. I want to move the social media items to the right of the footer. How would I achieve this? I have been playing around with flex but nothing is working yet.
<div className="mx-20 mb-20">
<Divider style={{ background: '#5E5E5E96' }} orientation="horizontal" />
<div className="mt-8 w-full flex">
<div>
<ul className="flex">
<span className="ml-8 mr-20">
<li>©2022 {name}</li>
</span>
<span className="flex space-x-20">
<li>Cookie Policy</li>
<li>Refund Policy</li>
<li>Privacy Policy</li>
<li>Terms & Conditions</li>
</span>
</ul>
</div>
<div className="icons flex">
<img src={InstagramIcon} alt="Instagram icon" />
<img src={FacebookIcon} alt="Facebook icon" />
<img src={TwitterIcon} alt="Twitter icon" />
<img src={Linkedin} alt="Linkedin icon" />
</div>
</div>
</div>
So I want the icons to be the same distance from the right as the first list item is from the left.
You can do this in multiple ways:
add justify-between
add ml-auto to the item you want to move.
In both cases, your flex container has to be 100% wide w-full.
You can add justify-between or justify-evenly on the outer most div that wraps both the list and the icons.
Below is the code
<div className="mx-20 mb-20">
<Divider style={{ background: '#5E5E5E96' }} orientation="horizontal" />
<div className="mt-8 w-full flex items-center justify-between">
<div>
<ul className="flex">
<span className="ml-8 mr-20">
<li>©2022 {name}</li>
</span>
<span className="flex space-x-20">
<li>Cookie Policy</li>
<li>Refund Policy</li>
<li>Privacy Policy</li>
<li>Terms & Conditions</li>
</span>
</ul>
</div>
<div className="icons flex">
<img src={InstagramIcon} alt="Instagram icon" />
<img src={FacebookIcon} alt="Facebook icon" />
<img src={TwitterIcon} alt="Twitter icon" />
<img src={Linkedin} alt="Linkedin icon" />
</div>
</div>
</div>
items-center is align them vertically

How to implement one2many field on odoo 15 website form

I have a custom module and i want to create a website form for my module. In the backend form the is a section where user enters service details through a one2many field. The form is to be made available to portal users on the website.How do i implement one2many field on the website so that the information can be recorded in backend??This is my backend form view
This is my website form.I've been able to do first part of form and need help with many2one
<template id="online_request_form">
<t t-call="portal.portal_layout">
<t t-set="breadcrumbs_searchbar" t-value="True"/>
<t t-call="portal.portal_searchbar">
<t t-set="title">Service Request</t>
</t>
<div id="wrap" class="oe_structure oe_empty">
<section class="s_website_form" data-vcss="001" data-snippet="s_website_form">
<div class="container">
<form action="/submit/request" method="post" enctype="multipart/form-data" class="o_mark_required" data-mark="*" data-model_name="" data-success-page="">
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
<table style="border:0px; width:100%%; background-color:#D6EEEE; margin-top:5%%;">
<group>
<tr>
<td>
<group>
<label class="col-form-label col-sm-auto s_website_form_label" style="width: 50%%" for="studio1">
<span class="s_website_form_label_content">Agency</span>
<span class="s_website_form_mark"> *</span>
</label>
<div class="col-sm">
<select name="agency" t-attf-class="form-control s_website_form_input" required="1">
<option value=""><i>Please Select</i></option>
<t t-foreach="agencies or []" t-as="agency">
<option t-att-value="agency.id">
<t t-esc="agency.name" />
</option>
</t>
</select>
</div>
</group>
<group>
<label class="col-form-label col-sm-auto s_website_form_label" style="width: 50%%" for="studio1">
<span class="s_website_form_label_content">Agent</span>
<span class="s_website_form_mark"> *</span>
</label>
<div class="col-sm">
<select name="agent" t-attf-class="form-control s_website_form_input" required="1">
<option value=""><i>Please Select</i></option>
<t t-foreach="agents or []" t-as="agent">
<option t-att-value="agent.id">
<t t-esc="agent.name" />
</option>
</t>
</select>
</div>
</group>
</td>
<td>
<group>
<label class="col-form-label col-sm-auto s_website_form_label" style="width: 50%%" for="studio1">
<span class="s_website_form_label_content"> IMDG Code / Un No.</span>
<span class="s_website_form_mark"> *</span>
</label>
<div class="col-sm">
<input id="imdg_code" type="text" class="form-control s_website_form_input" name="imdg_code" required="1"/>
</div>
</group>
<group>
<label class="col-form-label col-sm-auto s_website_form_label" style="width: 50%%" for="studio1">
<span class="s_website_form_label_content">Phone</span>
<span class="s_website_form_mark"> *</span>
</label>
<div class="col-sm">
<input id="phone" type="text" class="form-control s_website_form_input" name="phone" required="1"/>
</div>
</group>
</td>
</tr>
</group>
<tr>
<td>
<group>
<label class="col-form-label col-sm-auto s_website_form_label" style="width: 50%%" for="studio1">
<span class="s_website_form_label_content">Email</span>
<span class="s_website_form_mark"> *</span>
</label>
<div class="col-sm">
<input id="email" type="text" class="form-control s_website_form_input" name="email" required="1"/>
</div>
</group>
</td>
</tr>
</table>
<div style="width:200px; margin-top:2%%;" class="form-group col-12 s_website_form_submit" data-name="Submit Button">
<div class="s_website_form_label"/>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</section>
</div>
</t>
</template>
The template for website form.
#http.route('/service_requests', type='http', auth="user", website=True)
def service_request(self):
products = request.env['product.template'].sudo().search([])
agencies = request.env['res.partner'].sudo().search([])
agents = request.env['res.users'].sudo().search([])
values = {}
values.update({
'products': products,
'agencies': agencies,
'agents':agents,
'page_name': 'new_request',
})
return request.render("service_request.online_request_form", values)
Corresponding controller

How do you set a HTML data- tag for a ReactJS TextField in a form

I've got some automation that is looking for a HTML data- tag (example: "data-foobar"), and I have a login.js so that:
<div className={styles.whiteBoard}>
<main className={styles.content}>
<div>
<div className={styles.spacer}></div>
<form onSubmit={e => submit(e)}>
<TextField
className={styles.input}
label="Username"
autoFocus
variant="outlined"
margin="normal"
value={username}
onChange={e => setUsername(e.target.value)}
/>
</form>
</div>
</main>
where and how would one place a HTML data- tag in the above code?
You can use the inputProps object of the TextField to set the data attributes.
<TextField inputProps={{'data-foobar': 'foo bar'}}/>

ExpressJS only sending 200 status code for index on first load. 304 everytime after that

So I have a local project running ExpressJS and I'm using ejs as my template engine. Whenever I start the server and go to the home page the index.html file renders properly, but every subsequent load of the index gives me the un-rendered index.html file and the status is 304. All other pages render fine everytime. If I restart the server, the first time I hit the home page it is rendered correctly, but still serves the un-rendered file after every page load after that. If I put a breakpoint in the route (I'm using WebStorm) I can hit the break point the first time, but never again. I assume this is because of the 304. I also have app.disable('etag'). Any help is much appreciated.
UPDATE
This is what is the browser will display when receiving a 304 status.
<%- include('includes/header.html'); %>
<%- include('includes/navigation.html'); %>
<!-- Top Slider and Booking form -->
<div id="home-top-section">
<!-- Main Slider -->
<div id="main-slider">
<div class="items">
<a href="http://google.com">
<img src="assets/img/slider/1.jpg" alt="3"/><!-- Change the URL section based on your image\'s name -->
</a>
</div>
<div class="items">
<a href="http://google.com">
<img src="assets/img/slider/3.jpg" alt="3"/>
</a>
</div>
<div class="items">
<a href="http://google.com">
<img src="assets/img/slider/4.jpg" alt="4"/>
</a>
</div>
<div class="items">
<a href="http://google.com">
<img src="assets/img/slider/2.jpg" alt="2"/>
</a>
</div>
</div>
<!-- Booking Form -->
<div class="booking-form-container container">
<div class="booking-form-inner-container">
<div id="main-booking-form" class="style-2">
<h2>Find A <span>Room</span></h2>
<form class="booking-form clearfix" action="#"><!-- Do Not remove the classes -->
<div class="input-daterange clearfix">
<div class="booking-fields col-xs-6 col-md-12">
<input placeholder="Choose check in date" class="datepicker-fields check-in" type="text" name="start" /><!-- Date Picker field ( Do Not remove the "datepicker-fields" class ) -->
<i class="fa fa-calendar"></i><!-- Date Picker Icon -->
</div>
<div class="booking-fields col-xs-6 col-md-12">
<input placeholder="Choose check out date" class="datepicker-fields check-out" type="text" name="end" />
<i class="fa fa-calendar"></i>
</div>
</div>
<div class="booking-fields col-xs-6 col-md-12">
<!-- Select boxes ( you can change the items and its value based on your project's needs ) -->
<select name="room-type">
<option value="">How Many Adult?</option><!-- Select box items ( you can change the items and its value based on your project's needs ) -->
<option value="2">1</option>
<option value="3">2</option>
<option value="4">3</option>
<option value="5">4</option>
<option value="6">5</option>
</select>
<!-- End of Select boxes -->
</div>
<div class="booking-fields col-xs-6 col-md-12">
<select name="guest">
<option value="">How Many Children ?</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
<div class="booking-button-container">
<input class="btn btn-default" value="Check Availability" type="submit"/><!-- Submit button -->
</div>
</form>
</div>
</div>
</div>
</div>
<!-- End of Top Slider and Booking form -->
<!-- Luxury Rooms -->
<div id="luxury-rooms">
<!-- Heading box -->
<div class="heading-box">
<h2>Luxury <span>Rooms</span></h2><!-- Title -->
<div class="subtitle">Best rooms with Best services</div><!-- Subtitle -->
</div>
<!-- Room Box Container -->
<div class="room-container container">
<!-- Room box -->
<div class="room-boxes">
<img src="assets/img/rooms/1.jpg" alt="King Suit" class="room-img"><!-- Room Image -->
<div class="room-details col-xs-6 col-md-4">
<div class="title">King Suit</div><!-- Room title -->
<div class="description"><!-- Room Description -->
Short description of rooms will be located in this section that you can describe some special features and equipment of rooms. Visitors can get more information about this rooms by clicking on "Details" button.
</div>
Details<!-- Detail link -->
</div>
<div class="price-container col-xs-6 col-md-8">
<div class="price">
<span>$550</span>
- Per Night
</div>
</div>
</div>
<!-- Room box -->
<div class="room-boxes right">
<img src="assets/img/rooms/2.jpg" alt="Royal Suit" class="room-img">
<div class="room-details col-xs-6 col-md-4">
<div class="title">Royal Suit</div>
<div class="description">
Short description of rooms will be located in this section that you can describe some special features and equipment of rooms. Visitors can get more information about this rooms by clicking on "Details" button.
</div>
Details
</div>
<div class="price-container col-xs-6 col-md-8">
<div class="price">
<span>$490</span>
- Per Night
</div>
</div>
</div>
<!-- Room box -->
<div class="room-boxes">
<img src="assets/img/rooms/3.jpg" alt="Deluxe Two-bedroom Suite" class="room-img">
<div class="room-details col-xs-6 col-md-4">
<div class="title">Deluxe Two-bedroom Suite</div>
<div class="description">
Short description of rooms will be located in this section that you can describe some special features and equipment of rooms. Visitors can get more information about this rooms by clicking on "Details" button.
</div>
Details
</div>
<div class="price-container col-xs-6 col-md-8">
<div class="price">
<span>$370</span>
- Per Night
</div>
</div>
</div>
</div>
</div>
<!-- End of Luxury Rooms -->
<!-- Special Packages -->
<div id="special-packages" class="container">
<!-- Heading box -->
<div class="heading-box">
<h2>Special <span>Packages</span></h2><!-- Title -->
<div class="subtitle">Choose one of our special offers</div><!-- Subtitle -->
</div>
<!-- Package Container -->
<div class="package-container clearfix">
<!-- Package Box -->
<div class="package-box wow fadeInUp col-sm-6 col-md-4">
<div class="package-inner">
<div class="title">Diamond</div>
<div class="price"><span>$450</span>per night</div>
<div class="package-details">
<ul>
<li>Flight Ticket</li>
<li>Restaurant ( Lunch / Dinner )</li>
<li>Music Concert</li>
<li>Airport Pick-up</li>
<li>Sport Activities</li>
</ul>
</div>
Select Package
</div>
</div>
<!-- Package Box -->
<div class="package-box wow fadeInUp col-sm-6 col-md-4" data-wow-delay="0.5s">
<div class="package-inner">
<div class="title">Gold</div>
<div class="price"><span>$340</span>per night</div>
<div class="package-details">
<ul>
<li>Flight Ticket</li>
<li>Restaurant ( Lunch )</li>
<li>Music Concert ( 50% off )</li>
<li>Airport Pick-up</li>
<li>Sport Activities</li>
</ul>
</div>
Select Package
</div>
</div>
<!-- Package Box -->
<div class="package-box wow fadeInUp col-sm-6 col-md-4" data-wow-delay="1s">
<div class="package-inner">
<div class="title">Silver</div>
<div class="price"><span>$230</span>per night</div>
<div class="package-details">
<ul>
<li>Flight Ticket</li>
<li>Restaurant ( 20% off Lunch )</li>
<li>Music Concert ( 30% off )</li>
<li>Airport Pick-up</li>
<li>Sport Activities</li>
</ul>
</div>
Select Package
</div>
</div>
</div>
</div>
<!-- End of Special Packages -->
<!-- Gallery -->
<div id="gallery">
<!-- Heading box -->
<div class="heading-box">
<h2>Pinar <span>Gallery</span></h2><!-- Title -->
</div>
<!-- Gallery Container -->
<div class="gallery-container">
<div class="sort-section">
<div class="sort-section-container">
<div class="sort-handle">Filters</div>
<ul class="list-inline">
<li>All</li>
<li>Restaurant</li>
<li>Bars</li>
<li>Pool</li>
<li>Rooms</li>
<li>Lobby</li>
</ul>
</div>
</div>
<ul class="image-main-box clearfix">
<li class="item col-xs-6 col-md-3 lobby">
<figure>
<img src="assets/img/gallery/1.jpg" alt="11"/>
Enlarge
<figcaption>
<h4><span>Great</span> View</h4>
</figcaption>
</figure>
</li>
<li class="item col-xs-6 col-md-6 pool">
<figure>
<img src="assets/img/gallery/2.jpg" alt="11"/>
Enlarge
<figcaption>
<h4><span>Outdoor</span> Pool</h4>
</figcaption>
</figure>
</li>
<li class="item col-xs-6 col-md-3 bars">
<figure>
<img src="assets/img/gallery/3.jpg" alt="11"/>
Enlarge
<figcaption>
<h4><span>Delicious</span> Foods</h4>
</figcaption>
</figure>
</li>
<li class="item col-xs-6 col-md-3 restaurant">
<figure>
<img src="assets/img/gallery/4.jpg" alt="11"/>
Enlarge
<figcaption>
<h4><span>International</span> Foods</h4>
</figcaption>
</figure>
</li>
<li class="item col-xs-6 col-md-3 pool">
<figure>
<img src="assets/img/gallery/5.jpg" alt="11"/>
Enlarge
<figcaption>
<h4><span>Cozy</span> Spaces</h4>
</figcaption>
</figure>
</li>
<li class="item col-xs-6 col-md-3 rooms">
<figure>
<img src="assets/img/gallery/6.jpg" alt="11"/>
Enlarge
<figcaption>
<h4><span>Comfortable </span> Rooms</h4>
</figcaption>
</figure>
</li>
<li class="item col-xs-6 col-md-3 pool">
<figure>
<img src="assets/img/gallery/7.jpg" alt="11"/>
Enlarge
<figcaption>
<h4><span>Relaxation</span> Spaces</h4>
</figcaption>
</figure>
</li>
<li class="item col-xs-6 col-md-6 pool">
<figure>
<img src="assets/img/gallery/8.jpg" alt="11"/>
Enlarge
<figcaption>
<h4><span>Indoor</span> Pool</h4>
</figcaption>
</figure>
</li>
</ul>
More ...
</div>
</div>
<!-- End of Gallery -->
<%- include('includes/footer.html'); %>
instead of the rendered version. Notice the includes at the top and bottom of the page.
So, the issue was simply because I was using .html templates instead of .ejs. Word to the wise, if you buy a template that has static .html files and want to use a templating engine such as .ejs, make sure you change .html to .ejs or you will run into all types of issues.

How to add slot in repeat dom in polymer 2

i want to create a layout element, so i write the template like this
<template>
<div class="row">
<template is="dom-repeat" items="[[cols]]">
<div class$="col-[[item]]">
<slot id="id[[index]]" name="id[[index]]">no value</slot>
</div>
</template>
</div>
</template>
and in the html page file, i use this component like this:
<tcpc-row>
<span slot="id0">cc id-tcpc-col-0 </span>
<span slot="id1">cc id-tcpc-col-1 </span>
<span slot="id1">cc id-tcpc-col-3 </span>
</tcpc-row>
but i result is not correctly, when i write the template without repeat is ok, like this:
<template>
<div class="row">
<div class="col-3">
<slot name="id0"></slot>
</div>
<div class="col-3">
<slot name="id1"></slot>
</div>
<div class="col-3">
<slot name="id2"></slot>
</div>
<!--<template is="dom-repeat" items="[[cols]]">
<div class$="col-[[item]]">
<slot id="id[[index]]" name="id[[index]]">no value</slot>
</div>
</template>-->
</div>
</template>
is there have some way to add slot in repeat?
Try slotting the <div class="row">.

Resources