Display buttons In the certain format using ng-repeat - css

I am using angularjs and bootstrap3. I have array of array of objects and I need to display it in the UI like below,
sample = [
{
"id": 12,
"title": "title2",
"description": "description2_for the second"
},
{
"id": 13,
"title": "title3",
"description": "description3"
},
{
"id": 17,
"title": "title4",
"description": "description4"
},
{
"id": 18,
"title": "title5",
"description": "description5"
},
{
"id": 19,
"title": "title6",
"description": "description6"
},
{
"id": 20,
"title": "title7",
"description": "description7"
},
{
"id": 21,
"title": "title8",
"description": "description8"
},
{
"id": 22,
"title": "title9",
"description": "description9"
}
]
my code ng-repeat look like,
<div class="editor-preview">
<div class="row" >
<div class="col-md-4 " ng-repeat-start="i in sample track by $index">
<div class="tooltip"><button type="button" class="btn btn-primary btn-round-lg btn-lg">{{i.title}}</button>
<span class="tooltiptext">{{i.description}}</span>
</div>
</div>
<div class="clearfix" ng-if="($index+1)%3==0"></div>
<div ng-repeat-end=""></div>
</div>
</div>
From the above code, UI is looking like below image.
But, I want to show the UI like the below image and 3 buttons per row
How to show the UI like above image in bootstrap css dynamically for alternative rows too

You can use list-inline for this layout:
http://jsfiddle.net/hstppbj8/804/
HTML:
<div ng-controller="sample">
<div class="editor-preview-testimonials">
<div class="row">
<div class="col-xs-10">
<ul class="list-inline text-center">
<li ng-repeat="i in sample track by $index"><button class="btn btn-sm btn-primary">
{{i.title}}<span class="tooltiptext"> {{i.description}}</span>
</button></li>
</ul>
</div>
<div class="clearfix" ng-if="($index+1)%3==0"></div>
<div ng-repeat-end=""></div>
</div>
</div>
</div>
CSS:
ul li {
margin: 4px 0; /*For spacing between li*/
}
Resize the jsfiddle window to see the layout properly.

try to have the text for the content to be different ( some are longer, some are much longer ) for each of the button. It should be prolonged as the class ".btn" css has {display: inline-block} in them. Then make sure there is a wrapper around these buttons and make them { text-align: center }

In angular 1 ng-repeat has been used. But in ng-5 this syntax has been changed with ng-for. I would suggest you to please use the ng-for to use the angular loop. in that case Your code will be like the following.
<div ng-controller="sample">
<div class="editor-preview-testimonials">
<div class="row">
<div class="col-xs-10">
<ul class="list-inline text-center">
<li *ngFor="let item of items; let i = index""><button class="btn btn-sm btn-primary">
<span class="tooltiptext"> {{i}} {{description}}</span>
</button></li>
</ul>
</div>
<div class="clearfix" ng-if="($index+1)%3==0"></div>
</div>
</div>
</div>

Related

Horizontally centering a flex div with Tailwind

I have a few items inside a div that I can't seem to get to center horizontally using Tailwind - I think it's due to how I'm using flex?
<Row>
<div class={"flex items-center gap-6"}>
<div class="text-right">
<h1 class="text-4xl font-serif">
<em>Create</em> your account
</h1>
<p>We'll have you set up in a few short steps</p>
</div>
<div class="text-left">
<Form
data={{
name: {
label: "First Name",
type: "text",
required: true,
errorMessage: "Please enter your first name",
},
email: {
label: "Email",
type: "email",
required: true,
},
}}
/>
</div>
</div>
<div className="mt-4 text-center">
Already registered?{" "}
<Link
url="/signin"
className="text-pink-500 hover:text-pink-500 visited:text-pink-500"
text="Sign In"
/>
</div>
</Row>
Here's how it looks - the space on the right shouldn't be there

How to use reference in vuejs 3 inside for loop

I've been developing my first project with Vue3 js.I have tried to implement vue-signature pad inside for loop.I thnik vue signature pad is working based on ref. I have done vue-signature pad with out loop. But i dont know how to use ref inside loop. Anybody please help how to implement signature pad inside loop using vue3. Thank you in advance.
<template>
<div
class="row"
v-for="(applicants, index) in applicant_details"
:key="index"
>
<div class="col-sm-4">
<div class="form-group">
<p>Signature for {{ applicants.first_name }}</p>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<VueSignaturePad ref="" />
<button type="button" #click="undo1" class="btn btn-warning">
Undo
</button>
</div>
</div>
<div class="col-sm-2" style="margin-top: 40px; text-align: center">
<div class="form-group">
<button type="button" #click="undo" class="btn btn-danger">
Clear
</button>
</div>
</div>
<div class="col-sm-2">
<div class="form-group">
<button type="button" #click="save_signature" class="btn btn-success">
Save
</button>
</div>
</div>
</div>
</template>
<script>
export default {
data() {
return {
applicant_details: [
{ first_name: 'john', signature: '' },
{ first_name: 'david', signature: '' },
],
};
},
methods: {
undo() {
//will undo the signature
},
save_signature() {
//Save the signature
},
},
};
</script>
Be carefull, you have some issue with your code to begin with.
No template for you html
export default not well formated
List item
You original issue may be in --> v-for="(applicants, index) in 'applicant_details'"
Here it loop on the STRING 'applicant_details'. If you want to loop on a variable in your data juste use applicant_details.
U can also use vite.new/vue to create reproductive code and help us to help you.
Here is the corrected code : https://stackblitz.com/edit/vitejs-vite-9kvde4?file=src%2FApp.vue&terminal=dev

Displaying multiple columns in single carousel item with Bootstrap carousel

So I am able to have four columns in single item at a time , but when I implement 'carousel' class (4th div in html file) then the first two item displays fine. But in the last item as it should only have 2 columns with task name 9 and 10, instead task name 1 and 5 are also displayed there.
if I don't implement carousel class then data displays fine but carousel buttons stops working.
' I've already tried different solutions provided on stack overflow. '
here is my HTML file
<!-- my tasks -->
<div class="row mt-3 mb-3">
<div class="col-md-12">
<!-- carousel -->
<div class="row mx-auto my-auto">
<div id="myTaskDiv" class="carousel slide w-100" data-ride="carousel">
<div class="carousel-inner w-100">
<!-- carousel item -->
<div class="carousel-item {{ i == 0 ? 'active' : '' }}" *ngFor="let chunkMyTask of productData ;let i =index;">
<!--widget-->
<div class="col-sm-6 col-md-4 col-lg-3" *ngFor="let myTask of chunkMyTask">
<div class="widget border">
<div class="widget-body">
{{myTask.name}}
</div>
</div>
<!--widget end-->
</div>
<!-- carousel item end-->
</div>
</div>
<!-- carousel controls -->
<a class="carousel-control-prev" role="button" href="#myTaskDiv" data-slide="prev">
<i class="fa fa-angle-left fa-3x" aria-hidden="true"></i>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" role="button" href="#myTaskDiv" data-slide="next">
<i class="fa fa-angle-right fa-3x" aria-hidden="true"></i>
<span class="sr-only">Next</span>
</a>
<!-- carousel controls end-->
</div>
<!-- carousel end -->
</div>
</div>
<!-- my tasks end-->
then this below is my .ts file
import { Component, OnInit } from '#angular/core';
import { task } from '../task';
import { TasksService } from '../tasks.service';
import { MyTaskServiceService } from 'src/app/dashboard/my-tasks/my-task-service.service';
#Component({
selector: 'app-my-tasks',
templateUrl: './my-tasks.component.html',
styleUrls: ['./my-tasks.component.css']
export class MyTasksComponent {
title = 'Carousel';
productData: any;
private myTasks: any;
private myTaskArray: any;
constructor(private myTaskService: MyTaskServiceService) { }
chunks(array, size) {
let results :any;
results = [];
while (array.length) {
results.push(array.splice(0, size));
this.num=this.num+1;
}
return results;
}
ngOnInit() {
this.myTaskService.get_New_Products().subscribe(
data => {
this.productData = this.chunks(data.json(), 4);
console.log(this.productData);
});
}
}
And at last this below is my json file:
[
{
"taskType": "myTask",
"name": "Task 1"
},
{
"taskType": "myTask",
"name": "Task 2"
},
{
"taskType": "myTask",
"name": "Task 3"
},
{
"taskType": "myTask",
"name": "Task 4"
},
{
"taskType": "myTask",
"name": "Task 5"
},
{
"taskType": "myTask",
"name": "Task 6"
},
{
"taskType": "myTask",
"name": "Task 7"
},
{
"taskType": "myTask",
"name": "Task 8"
},
{
"taskType": "myTask",
"name": "Task 9"
},
{
"taskType": "myTask",
"name": "Task 10"
}
]

Odoo 8 qweb report style modification

I am trying to modify my qweb report contents in Oddo 8 I am using div position. I want to hide fax field on print view. How can i do? It is not working.I am trying to css like display none.
Here below is my code
this is my final code
<openerp>
<data>
<template id="report_picking_inherit_demo" inherit_id="stock.report_picking">
<xpath expr="//div[hasclass('page')]/div[hasclass('row')]" position="replace">
<div class="col-xs-6">
<div t-if="o.picking_type_id.code=='incoming' and o.partner_id">
<span>
<strong>Supplier Address:</strong>
</span>
</div>
<div t-if="o.picking_type_id.code=='internal' and o.partner_id">
<span>
<strong>Warehouse Address:</strong>
</span>
</div>
<div t-if="o.picking_type_id.code=='outgoing' and o.partner_id">
<span>
<strong>Customer Addresswww:</strong>
</span>
</div>
<div t-if="o.partner_id" name="partner_header">
<div t-field="o.partner_id"
t-field-options='{"widget": "contact", "fields": ["address", "name", "phone"], "no_marker": true}'/>
</div>
</div>
<div class="col-xs-5 col-xs-offset-1">
<div t-if="o.move_lines and o.move_lines[0].partner_id and o.move_lines[0].partner_id.id != o.partner_id.id">
<span>
<strong>Delivery Address:</strong>
</span>
<div t-field="o.move_lines[0].partner_id"
t-field-options='{"widget": "contact", "fields": ["address", "name", "phone","fax"], "no_marker": true}'/>
</div>
<div t-if="o.picking_type_id.code != 'internal' and (not o.move_lines or not o.move_lines[0].partner_id) and o.picking_type_id.warehouse_id.partner_id">
<span>
<strong>Warehouse Address:</strong>
</span>
<div t-field="o.picking_type_id.warehouse_id.partner_id"
t-field-options='{"widget": "contact", "fields": ["address", "name", "phone","fax"], "no_marker": true}'/>
</div>
</div>
</xpath>
</template>
</data>
Here I entered fax something example
https://i.stack.imgur.com/iIUCo.png
after that this result
https://i.stack.imgur.com/ukxTI.png]
Remove field 'fax' from the list,
*.xml
<div t-field="o.partner_id"
t-field-options='{"widget": "contact", "fields": ["address", "name", "phone"], "no_marker": true}'/>
You need to remove fax attribute from t-options and you can achieve that by inheriting the original template and overriding <div t-field="o.partner_id"... element.
<template id="custom_report_picking" inherit_id="stock.report_picking">
<xpath expr="//t/t/t/t/div/div/div/div[2]/div" position="replace">
<div t-field="o.partner_id"
t-field-options='{"widget": "contact", "fields": ["address", "name", "phone"], "no_marker": true}'/>
</xpath>
</template>

Foudation grid system not working on Angular Form

I have done the intsallation of foundation 6 on my Angular and it works fine but I realized the grid system is not working at all. I have made a lot of tweaks and turns but still no luck. Anyone knows why this may be. Thank you.
<div>
<h3>
Add A Warehouse
</h3>
</div>
<form novalidate [formGroup]= "warehouseForm" (ngSubmit)="onSubmitForm()">
<div class="row">
<div class="medium-6 columns">
<label>Warehouse Name
<span>
<i class="fa fa-user"></i>
</span>
<input type="text" placeholder="Warehouse Name">
</label>
</div>
<div class="medium-6 columns">
<label>Warehouse Country
<span>
<i class="fa fa-user"></i>
</span>
<input type="text" placeholder="Warehouse Country">
</label>
</div>
</div>
<div class="row">
<div class="medium-6 columns">
<label>Warehouse Region
<span>
<i class="fa fa-user"></i>
</span>
<input type="text" placeholder="Warehouse Region">
</label>
</div>
<div class="medium-6 columns">
<label>Warehouse City
<span>
<i class="fa fa-user"></i>
</span>
<input type="text" placeholder="Warehouse City">
</label>
</div>
</div>
<div class="row">
<div class="medium-6 columns">
<label>Warehouse Address
<span>
<i class="fa fa-user"></i>
</span>
<input type="text" placeholder="Warehouse Address">
</label>
</div>
<div class="medium-6 columns">
<label>Warehouse Street
<span>
<i class="fa fa-user"></i>
</span>
<input type="text" placeholder="Warehouse Street">
</label>
</div>
</div>
<div class="row">
<div class="medium-6 columns end">
<label>Warehouse Keeper
<span>
<i class="fa fa-user"></i>
</span>
<input type="text" placeholder="Warehouse Keeper">
</label>
</div>
</div>
<div>
<button type="submit" class="success button expanded">Save</button>
</div>
</form>
This is my form , I can say I say my foundation works because the fonts and other things are working. But the grid is just not working.
In the .angular-cli.json
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"../node_modules/foundation-sites/dist/css/foundation.css",
"../node_modules/font-awesome/css/font-awesome.css",
"styles.css"
],
"scripts": [
"../node_modules/foundation-sites/vendor/jquery/dist/jquery.js",
"../node_modules/foundation-sites/dist/js/foundation.js"
],
Image from code inspection
I think the issue is with the version of foundation you've got!
Check what grid system your current install of Foundation is using because the newest version of Foundation comes with their XY Grid enabled when you download the complete package and this wont call the CSS of the old grid!
You'll need to re-download a custom version of Foundation but check 'float grid' when you're downloading it and it will get you back to the older grid system and your code should work!
Heres a link to download the custom foundation version:
https://foundation.zurb.com/sites/download/
And if you want to learn more about the new XY Grid heres a link: http://foundation.zurb.com/sites/docs/xy-grid.html
Hope this helps!
In case anyone else has an issue with using Foundation Flex Grid:
Try adding these in your styles.scss:(you could read more from here)
#import "../node_modules/foundation-sites/assets/foundation";
#include foundation-flex-classes;
#include foundation-flex-grid;
If that did work, here's how I add foundation to my Angular 8 project:
Install foundation sites and jQuery:
$ npm install --save foundation-sites jquery
Add these in angular.json file:
"styles": [
"src/styles.scss",
"node_modules/foundation-sites/dist/css/foundation.min.css"
],
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/foundation-sites/dist/js/foundation.min.js"
],
Add $ and foundation in app.component.ts
-
import { Component } from '#angular/core';
declare var $: any; // <=========== Add this
#Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = 'app-frontend';
ngOnInit(): void {
$(document).foundation(); // <=========== Add this
}
}
Ctrl C and npm start or ng serve again to reset the server.

Resources