Print md-dialog content with scroll bar - css

I have a long report made with md-list that is shown in a md-dialog, but when I try to print it, it only shows the section which i'm seeing on the screen no the entire length of the md-list. I have tryed this css tricks on #media:
#media print {
.grid-comissoes {
height: 100%;
width: 100%;
position: absolute;
overflow: hidden;
zoom: 0.8;
.grid-wrapper {
min-width: 0;
}
}
}
this is the part i'm trying to print:
<md-dialog-content class="md-dialog-content">
<div layout="row" layout-align="start center" layout-padding class="sd-mixed-row grey">
<span class="grey">Comissões a partir de</span>
<md-input-container flex="20" flex-xs="50" layout-no-padding>
<label>Início</label>
<input sd-datepicker="{changeMonth: false, changeYear: false}" ng-change="detalheCtrl.load()" aria-label="Início do período" ng-model="detalheCtrl.filter.startDh" ng-model-options="{debounce:300}">
</md-input-container>
<span class="grey">até</span>
<md-input-container flex="20" flex-xs="50" layout-no-padding>
<label>Fim</label>
<input sd-datepicker="{changeMonth: false, changeYear: false}" ng-change="detalheCtrl.load()" aria-label="Fim do período" ng-model="detalheCtrl.filter.endDh" ng-model-options="{debounce:300}">
</md-input-container>
</div>
<div layout="row" ng-if="detalheCtrl.loading" layout-align="center center">
<md-progress-circular md-mode="indeterminate"></md-progress-circular>
</div>
<div layout="column" ng-if="!detalheCtrl.loading">
<md-list layout-fill-width class="grey md-body-1 grid-comissoes" ng-repeat="regra in detalheCtrl.regrasComissoes">
<md-list-item layout="row" class="regra-header">
{{ detalheCtrl.getInfoRegra(regra) }}
</md-list-item>
<div class="grid-wrapper" ng-if="regra.tipoPagamento === 1">
<md-list-item layout="row">
<span>Finalizado em</span>
<span flex="20">Paciente</span>
<span flex>Tratamento</span>
<span>Valor do tratamento</span>
<span>Comissão</span>
</md-list-item>
<md-divider></md-divider>
<div ng-repeat="recebimentoTratamento in regra.recebimentosTratamentos">
<md-list-item layout="row">
<span>{{ recebimentoTratamento.tratamento.dataFinal | dateFormat }}</span>
<span flex="20">{{ recebimentoTratamento.tratamento.paciente.nome }}</span>
<span flex>{{ recebimentoTratamento.tratamento.procedimento.nome }} {{ recebimentoTratamento.tratamento.denteDTO.nome }}</span>
<span>
{{ recebimentoTratamento.tratamento.valor | currency }}
</span>
<span>{{ recebimentoTratamento.valorCalculadoComissao | currency }}</span>
</md-list-item>
<md-divider></md-divider>
</div>
<md-list-item layout="row" class="footer-grid">
<span></span>
<span flex="20"></span>
<span flex></span>
<span></span>
<span>Total</span>
<span>{{ regra.total | currency }}</span>
</md-list-item>
</div>
<div class="grid-wrapper" ng-if="regra.tipoPagamento === 2">
<md-list-item layout="row">
<span>Pago em</span>
<span flex="20">Paciente</span>
<span flex>Tratamento</span>
<span flex="20">Valor Pago</span>
<span>Parcela</span>
<span>Comissão</span>
</md-list-item>
<md-divider></md-divider>
<div ng-repeat="recebimentoTratamento in regra.recebimentosTratamentos">
<md-list-item layout="row">
<span>{{ recebimentoTratamento.recebimento.dataPagamento | dateFormat }}</span>
<span flex="20">{{ recebimentoTratamento.tratamento.paciente.nome }}</span>
<span flex>{{ recebimentoTratamento.tratamento.procedimento.nome }} {{ recebimentoTratamento.tratamento.denteDTO.nome }}</span>
<div layout="row" flex="20">
<span ng-if="!detalheCtrl.showInfo(recebimentoTratamento)" flex>{{ recebimentoTratamento.valor | currency }}</span>
<span ng-if="detalheCtrl.showInfo(recebimentoTratamento)" flex>
{{ recebimentoTratamento.valor | currency }} de {{ recebimentoTratamento.recebimento.valor | currency }}
<md-icon style="fill: #2193D7 !important;" class="info-popover-comissao" md-svg-icon="info-full" ng-if="detalheCtrl.showInfo(recebimentoTratamento)">
<sd-popover class="popover-comissoes" event="hover" align="bottom center">
<div layout="column" class="md-body-1 grey">
<span>O paciente pagou a parcela {{ recebimentoTratamento.recebimento.parcela }}/{{recebimentoTratamento.recebimento.numeroDeParcelas}} de {{ recebimentoTratamento.recebimento.valor | currency }} para a clínica.</span>
<span layout-margin-top>A comissão da {{ detalheCtrl.profissional.nome }} será gerada apenas sobre o valor de {{ recebimentoTratamento.valor | currency }} correspondente ao tratamento {{ recebimentoTratamento.tratamento.procedimento.nome }}.</span>
<span layout-margin-top>O restante do recebimento é referente a tratamentos realizados por outros profissionais.</span>
</div>
</sd-popover>
</md-icon>
</span>
</div>
<span>{{ recebimentoTratamento.recebimento.parcela }}/{{recebimentoTratamento.recebimento.numeroDeParcelas}}</span>
<span>{{ recebimentoTratamento.valorCalculadoComissao | currency }}</span>
</md-list-item>
<md-divider></md-divider>
</div>
<md-list-item layout="row" class="footer-grid">
<span></span>
<span flex="20"></span>
<span flex></span>
<span></span>
<span>Total</span>
<span>{{ regra.total | currency }}</span>
</md-list-item>
</div>
</md-list>
<div layout="column" layout-align="center end" layout-margin-top>
<span layout-margin-top>Total a pagar {{ detalheCtrl.total | currency }}</span>
</div>
</div>
</md-dialog-content>

I think it's already reported in the angular repo
however you can get a simple workaround by setting up manually a descent height for your modal:
config: MdDialogConfig = {
disableClose: true,
width: '',
height: '600px',
position: {
top: '',
bottom: '',
left: '',
right: ''
}
};

Related

How to inline radio buttons in a django form?

Here's the radio buttons:
account_type = forms.ChoiceField(
choices=enumerate(('Choice 1', 'Choice 2')),
widget=forms.RadioSelect(
{'class': 'form-check form-check-inline', 'style': 'margin-left: 20px'}
),
label='',
)
I'm using bootstrap-nightshade for styling which possibly contains something that prevents inlining the buttons. So far I tried:
display: inline
and
display: inline-block;
and
class="radio-inline"
Nothing works. Here's the template of the form
{% extends 'index.html' %}
{% load bootstrap5 %}
{% block content %}
<section class="h-100">
<div class="container h-100">
<div class="row justify-content-sm-center h-100">
<div class="col-xxl-4 col-xl-5 col-lg-5 col-md-7 col-sm-9">
<div class="card shadow-lg">
<div class="card-body p-5">
<h4>{{ form_title }}</h4>
<form method="post">
{% csrf_token %}
{% bootstrap_form form %}
<button class="btn btn-success">{{ form_title }}</button>
{% if form_title == 'Sign in' %}
<a style="margin-left: 15px" href={% url 'reset-password' %}>Forgot password?</a>
{% endif %}
</form>
</div>
</div>
</div>
</div>
</div>
</section>
{% endblock %}
and here's how they are rendered:
<div class="mb-3">
<div class="form-check form-check-inline" id="id_choices">
<div>
<label for="id_choices_0"><input class="form-check form-check-inline" id="id_choices_0"
name="choices" required="" style="margin-left: 20px" title=""
type="radio" value="0">
Choice 1</label>
</div>
<div>
<label for="id_choices_1"><input class="form-check form-check-inline" id="id_choices_1"
name="choices" required="" style="margin-left: 20px" title=""
type="radio" value="1">
Choice 2</label>
</div>
</div>
</div>

Call JavaScript function from Twig (symfony 5)

I'm working on a Symfony5 project and I want to call a JavaScript function and pass an Ajax Request (which I get from a controller) from a Twig.
i create a function phoneverif() in order to do some verification before the validation of form ..like doing a test if the fields are blanks then an alert will appears also the verification of the existence of data in db.
But a first, very simple test already failed, and an error appear :
Uncaught ReferenceError: phoneverif is not defined
onclick http://localhost:8000/super_admin/telephone/nouveau:1
here is my twig code :
{% extends 'superadmin.html.twig'%}
{% block body %}
<div class="container-fluid">
<!-- Page Heading -->
<h1 class="h3 mb-4 text-gray-800">Nouveau téléphone</h1>
</div>
<div class="col-md-12">
{% for flashMessage in app.session.flashbag.get('notice') %}
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h4><i class="icon fa fa-check"></i>{{ flashMessage }}</h4>
</div>
{% endfor %}
<!-- general form elements -->
<div>
<!-- form start -->
{{ form_start(form)}}
<div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>{{ form_label(form.userGroup) }}</label>
{{ form_widget(form.userGroup) }}
<span class="text-danger">{{ form_errors(form.userGroup) }}</span>
</div>
<div class="form-group">
<label>{{ form_label(form.protocol) }}</label>
{{ form_widget(form.protocol) }}
<span class="text-danger">{{ form_errors(form.protocol) }}</span>
</div>
<div class="form-group">
<label>{{ form_label(form.extension) }}</label>
{{ form_widget(form.extension) }}
<span class="text-danger">{{ form_errors(form.extension) }}</span>
</div>
<div class="form-group">
<label>{{ form_label(form.dialplanNumber) }}</label>
{{ form_widget(form.dialplanNumber) }}
<span class="text-danger">{{ form_errors(form.dialplanNumber) }}</span>
</div>
<div class="form-group">
<label>{{ form_label(form.voicemailId) }}</label>
{{ form_widget(form.voicemailId) }}
<span class="text-danger">{{ form_errors(form.voicemailId) }}</span>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>{{ form_label(form.login) }}</label>
{{ form_widget(form.login) }}
<span class="text-danger">{{ form_errors(form.login) }}</span>
</div>
<div class="form-group">
<label>{{ form_label(form.pass) }}</label>
{{ form_widget(form.pass) }}
<span class="text-danger">{{ form_errors(form.pass) }}</span>
</div>
<div class="form-group">
<label>{{ form_label(form.confSecret) }}</label>
{{ form_widget(form.confSecret) }}
<span class="text-danger">{{ form_errors(form.confSecret) }}</span>
</div>
<div class="form-group">
<label>{{ form_label(form.serverIp) }}</label>
{{ form_widget(form.serverIp) }}
<span class="text-danger">{{ form_errors(form.serverIp) }}</span>
</div>
</div>
</div>
</div>
<div>
<button type="button" class="btn btn-primary" onclick="phoneverif();">Ajouter</button>
<a class="btn btn-warning" href="{{ path('Les_telephones') }}">Retour</a>
</div>
{{ form_end(form)}}
</div>
</div>
</div>
{% endblock %}
{% block javascripts %}
<script src="{{ asset('bundles/fosjsrouting/js/router.js') }}"></script>
<script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}"></script>
<script type="text/javascript">
function phoneverif() {
if ($("#telephone_extension").val() == '') {
alert('Vous devez saisir une extension');
} else {
if ($("#telephone_dialplanNumber").val() == '') {
alert('Vous devez saisir le dialplan du téléphone');
} else {
if ($("#telephone_login").val() == '') {
alert('Vous devez saisir le login du téléphone');
} else {
if ($("#telephone_pass").val() == '') {
alert('Vous devez saisir le mot de passe du téléphone');
} else {
$.ajax({
type: 'get',
url: Routing.generate('phone_verif', {extension: $("#telephone_extension").val()}),
success: function (data) {
if (data.existe == 1) {
alert('Téléphone non valide');
} else {
$("form").submit();
}
},
error: function() { alert('Erreur lors de l'appel AJAX'); }
});
}
}
}
}
}
</script>
{% endblock %}
function verifphone :
public function Phoneverif1(Request $request , $extension){
if ($request->isXmlHttpRequest()) {
$em = $this->getDoctrine()->getManager();
$phone = $em->getRepository(Phones::class)->findOneByExtension($extension);
if ($phone) {
$existe = 1;
} else {
$existe = 0;
}
$response = new JsonResponse();
return $response->setData(array('existe' => $existe));
} else {
throw new \Exception('Erreur');
}
}
my fosjsrouting configuration :
config/packages/routing.yaml:
framework:
router:
utf8: true
# Configure how to generate URLs in non-HTTP contexts, such as CLI commands.
# See https://symfony.com/doc/current/routing.html#generating-urls-in-commands
#default_uri: http://localhost
fos_js_routing:
routes_to_expose: [ phone_verif ]
config/routes/fos_js_routing.yaml:
fos_js_routing:
resource: "#FOSJsRoutingBundle/Resources/config/routing/routing.xml"
routes.yaml :
verification_telephone:
path: /verification/phone/{extension}
controller: App\Controller\TelephoneController::Phoneverif1
options:
expose: true
Rename the function and try again
I solved this problem by renaming the function. You try too.
Phoneverif1()
{% extends 'superadmin.html.twig'%}
{% block body %}
<div class="container-fluid">
<!-- Page Heading -->
<h1 class="h3 mb-4 text-gray-800">Nouveau téléphone</h1>
</div>
<div class="col-md-12">
{% for flashMessage in app.session.flashbag.get('notice') %}
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h4><i class="icon fa fa-check"></i>{{ flashMessage }}</h4>
</div>
{% endfor %}
<!-- general form elements -->
<div>
<!-- form start -->
{{ form_start(form)}}
<div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>{{ form_label(form.userGroup) }}</label>
{{ form_widget(form.userGroup) }}
<span class="text-danger">{{ form_errors(form.userGroup) }}</span>
</div>
<div class="form-group">
<label>{{ form_label(form.protocol) }}</label>
{{ form_widget(form.protocol) }}
<span class="text-danger">{{ form_errors(form.protocol) }}</span>
</div>
<div class="form-group">
<label>{{ form_label(form.extension) }}</label>
{{ form_widget(form.extension) }}
<span class="text-danger">{{ form_errors(form.extension) }}</span>
</div>
<div class="form-group">
<label>{{ form_label(form.dialplanNumber) }}</label>
{{ form_widget(form.dialplanNumber) }}
<span class="text-danger">{{ form_errors(form.dialplanNumber) }}</span>
</div>
<div class="form-group">
<label>{{ form_label(form.voicemailId) }}</label>
{{ form_widget(form.voicemailId) }}
<span class="text-danger">{{ form_errors(form.voicemailId) }}</span>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>{{ form_label(form.login) }}</label>
{{ form_widget(form.login) }}
<span class="text-danger">{{ form_errors(form.login) }}</span>
</div>
<div class="form-group">
<label>{{ form_label(form.pass) }}</label>
{{ form_widget(form.pass) }}
<span class="text-danger">{{ form_errors(form.pass) }}</span>
</div>
<div class="form-group">
<label>{{ form_label(form.confSecret) }}</label>
{{ form_widget(form.confSecret) }}
<span class="text-danger">{{ form_errors(form.confSecret) }}</span>
</div>
<div class="form-group">
<label>{{ form_label(form.serverIp) }}</label>
{{ form_widget(form.serverIp) }}
<span class="text-danger">{{ form_errors(form.serverIp) }}</span>
</div>
</div>
</div>
</div>
<div>
<button type="button" class="btn btn-primary" onclick="Phoneverif1()">Ajouter</button>
<a class="btn btn-warning" href="{{ path('Les_telephones') }}">Retour</a>
</div>
{{ form_end(form)}}
</div>
</div>
</div>
{% endblock %}
{% block javascripts %}
<script src="{{ asset('bundles/fosjsrouting/js/router.js') }}"></script>
<script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}"></script>
<script type="text/javascript">
function Phoneverif1() {
if ($("#telephone_extension").val() == '') {
alert('Vous devez saisir une extension');
} else {
if ($("#telephone_dialplanNumber").val() == '') {
alert('Vous devez saisir le dialplan du téléphone');
} else {
if ($("#telephone_login").val() == '') {
alert('Vous devez saisir le login du téléphone');
} else {
if ($("#telephone_pass").val() == '') {
alert('Vous devez saisir le mot de passe du téléphone');
} else {
$.ajax({
type: 'get',
url: Routing.generate('phone_verif', {extension: $("#telephone_extension").val()}),
success: function (data) {
if (data.existe == 1) {
alert('Téléphone non valide');
} else {
$("form").submit();
}
},
error: function() { alert('Erreur lors de l'appel AJAX'); }
});
}
}
}
}
}
</script>
{% endblock %}

How to make title and date on one line in angular material

I have a title and date , but they are looking now like this:
title
date
but it has to be: title date.
<mat-card-header>
<mat-card-title >
<span [innerHTML]="item.title | highlight : searchQuery"></span>
<span class="spacer"></span>
<span>
<a mat-icon-button [routerLink]="['../', dossier.id , 'item', item.id]" i18n-title title="Edit">
<mat-icon>edit</mat-icon>
</a>
</span>
</mat-card-title>
<mat-card-subtitle >
<span *ngIf="!createdAtEqualsDate(item)">{{item.date | date: 'shortDate'}} <ng-template i18n>created</ng-template></span>
<span>{{item.createdAt | date: 'short'}}</span>
<span *ngIf="item.createdAt !== item.lastModifiedAt"><ng-template i18n>modified</ng-template> {{item.lastModifiedAt | date: 'short'}}</span>
</mat-card-subtitle>
</mat-card-header>
css:
mat-card-header{
justify-content: center;
}
So what I mean is that card-title and card-subtitle are on the same line and not under each other
I tried this example https://jsfiddle.net/VanessaRC/Lz9vz6bs/1/. But that doesnt fix it. Because I have a mat-card-header
oke, I have it now like this:
<mat-card-header>
<mat-card-title>
<span [innerHTML]="item.title | highlight: searchQuery"></span>
<span class="spacer"></span>
</mat-card-title>
<div class="title-date">
<span *ngIf="!createdAtEqualsDate(item)"
>{{ item.date | date: 'shortDate' }}<ng-template i18n>created</ng-template></span
>
<span>{{ item.createdAt | date: 'short' }}</span>
<span *ngIf="item.createdAt !== item.lastModifiedAt"
><ng-template i18n>modified</ng-template> {{ item.lastModifiedAt | date: 'short' }}</span
>
</div>
<span>
<a mat-icon-button [routerLink]="['../', dossier.id, 'item', item.id]" i18n-title title="Edit">
<mat-icon>edit</mat-icon>
</a>
</span>
</mat-card-header>
But then the date is on the left side next to the edit icon. But It has to be next to the title
You can add this to your styles, you will need to make a little more adjustments
.mat-card-header-text{
display: flex;
}
You could also use
.mat-card-header-text{
display: inline-block;
}
https://www.w3schools.com/css/css_inline-block.asp

Twig `Variable does not exist` error despite it not being printed

I'm trying to handle non existing variables in my controller which if the database is empty will return a view without any variables:
if(!$votes->findOneById(1) || !$images->findOneById(1)){
return $this->render('admin/stats_and_images.html.twig');
}
return $this->render('admin/stats_and_images.html.twig', [
'images' => $images->countVotesForAllImages(),
'image_podium' => $images->getTopNImages(3),
'form' => $form->createView(),
'votesToday' => $votes->votesToday(),
'votesMonth' => $votes->votesMonth(),
'votesTotal' => $votes->votesTotal()
]);
And in my view I'm trying to handle the lack of variables like so:
{% if (votesTotal[0][1] is defined) and (votesToday[0][1] is defined) and (votesMonth[0][1] is defined) %}
<div class="col-md-6">
<h4 class="sub-section--header">Liczba Oddanych Głosów:</h4>
<hr>
<p>
<div class="col-sm-6">
Dzisiaj:
<span class="text-info large-num">{{ votesToday[0][1] }}</span>
</div>
<div class="col-sm-6">
Ten miesiąc:
<span class="text-info large-num">{{ votesMonth[0][1] }}</span>
</div>
</p>
<p>
<strong>Głosów ogółem: </strong><span class="text-info large-num">{{ votesTotal[0][1] }}</span>
</p>
</div>
<div class="col-md-6">
<h4 class="sub-section--header">Wygrywające zdjęcia:</h4>
<p class="text-muted">Ten miesiąc</p>
<hr>
<div class="row text-center">
<div class="col-md-4">
<a
href="{{ asset("uploads/"~image_podium[0][0].fileName) }}"
target="blank">
<img
src="{{ asset("uploads/"~image_podium[0][0].fileName) | imagine_filter('my_thumb') }}" alt="{{image_podium[0][0].title}}"
class="site-thumbnail"
title="{{image_podium[0][0].title}} - {{image_podium[0][0].author}}">
</a>
<p><strong>Głosów: {{image_podium[0]['votes']}}</strong></p>
</div>
<div class="col-md-4">
<a
href="{{ asset("uploads/"~image_podium[1][0].fileName) }}"
target="blank">
<img
src="{{ asset("uploads/"~image_podium[1][0].fileName) | imagine_filter('my_thumb') }}" alt="{{image_podium[1][0].title}}"
class="site-thumbnail"
title="{{image_podium[1][0].title}} - {{image_podium[1][0].author}}">
</a>
<p>Głosów: {{image_podium[1]['votes']}}</p>
</div>
<div class="col-md-4">
<a
href="{{ asset("uploads/"~image_podium[2][0].fileName) }}"
target="blank">
<img
src="{{ asset("uploads/"~image_podium[2][0].fileName) | imagine_filter('my_thumb') }}" alt="{{image_podium[2][0].title}}"
class="site-thumbnail"
title="{{image_podium[2][0].title}} - {{image_podium[2][0].author}}">
</a>
<p>Głosów: {{image_podium[2]['votes']}}</p>
</div>
</div>
</div>
{% else %}
<h2 class="text-danger text-center">
No votes at the moment :)
</h2>
{% endif %}
But still despite the strict requirement of all three fields to be defined I'm getting this:
Variable "votesToday" does not exist.
And pointing to the <span class="text-info large-num">{{ votesToday[0][1] }}</span> portion of the view.
Why would this be happening? How can it be avoided?
send $votes to twig and check it with {{ dump(votes) }}
If it is a doctrine entity, check your getter. Perhaps is $votes->getVotesToday()

Bootstrap's thumbnails not displayed horizontally in Laravel 5.2

I'm trying to create a view where I show the bootstrap thumbnails on the same line, I've tried different methods and I'm showing thumbnails type list.
Here is my method in the controller:
public function show($id)
{
$properties = Property::find($id);
$files = File::where('property_id', $properties->id)->get();
return view('properties.show', compact('properties', 'files'));
}
This is my method in the view:
#foreach($properties->files as $index=>$file)
<div class="row">
<div class="col-sm-6 col-md-2">
<div class="thumbnail">
<img src="{{ URL::asset('uploads/products/' . $file->name) }}" alt="{{ $file->property_id }}" width="300" height="200">
<div class="caption">
<div class="caption" align="center">
<button onclick="return confirm('Está seguro eliminar esta imagen?')" class="button btn btn-danger btn-xs" data-toggle="tooltip" data-placement="top" title="Eliminar"><i class="material-icons delete-white">delete</i></button>
</div>
</div>
</div>
</div>
</div>
#endforeach
This way they are showing the images as thumbnails:
This should be the right way:
Can someone guide me to correct this small inconvenience?
You should loop inside your .row. The foreach method just repeats every code inside of it. So it was repeating <div class="row">...</div> every single time.
<div class="row">
#foreach($property->files as $index => $file)
<div class="col-sm-6 col-md-2">
<div class="thumbnail">
<img src="{{ URL::asset('uploads/products/' . $file->name) }}" alt="{{ $file->property_id }}" width="300" height="200">
<div class="caption">
<div class="caption" align="center">
<button onclick="return confirm('Está seguro eliminar esta imagen?')" class="button btn btn-danger btn-xs" data-toggle="tooltip" data-placement="top" title="Eliminar"><i class="material-icons delete-white">delete</i></button>
</div>
</div>
</div>
</div>
#endforeach
</div>

Resources