Could anyone advise how I can style elements so that the p fields were below input fields?
I tried to do so but unfortunatelly I do not know how to do it correctly.
The code:
<template>
<form #submit.prevent class="row justify-content-center">
<input
ref="input"
type="text"
class="input-box"
style="display: block"
v-model="$store.state.medicineNameInput"
v-on:keydown.enter.prevent="addMedicine"
placeholder="Input a medicine"
/>
<p
class="validation"
v-if="getMedicineNameInput === '' || getMedicineNameInput.trim() === ''"
>
This field cannot be empty.
</p>
<p class="validation" v-else-if="getMedicineNameInput.length < 3">
You need to input at least three characters.
</p>
<input
ref="input"
type="date"
class="input-box"
v-model="$store.state.medicineExpiryDateInput"
v-on:keydown.enter.prevent="addMedicine"
placeholder="Input expiry date"
/>
<p class="validation" v-if="getMedicineExpiryDateInput === ''">
Please input a valid date.
</p>
<button
type="submit"
v-if="
getMedicineNameInput.length >= 3 &&
getMedicineExpiryDateInput.length === 10
"
#click="addMedicine"
class="btn btn-warning"
>
Add a medicine
</button>
</form>
</template>
The elements on the page:
I would be gratefull for advice.
Try to wrap every input and paragraph inside a section tag
and give it styles ->
display : “flex”
flex-direction:”column”
It should display the elements below each other
Related
Datepicker (https://i.stack.imgur.com/vvCOX.png)
There is my code:
<div class="form-inline ">
<div class="input-group mt-2 mb-3" style="width:270px;">
<span class="input-group-text">Geb.-Datum:</span>
<input type="date" class="form-control" id="gebdat" >
</div>
</div>
Hello, I tried to size the input field but there is none appropriate width like the style attribute. Can someone pls help?
I tried w-25 and w-50, but it is not appropriate.
I am using vuejs-datepicker in my application inside a form. https://www.npmjs.com/package/vuejs-datepicker
My form structure looks something like this
<form #submit.prevent="submitForm">
<div v-show="claimRelatedTo === 'Sales Team'" class="form-group">
<label for="incentiveTypeSelect" class="col-form-label required">Incentive Type</label>
<div class="imported input-styling width75" id="incentiveTypeSelect">
<multi-select
v-model="newClaimForm"
placeholder="Select Incentive Type"
:options="list"
:multiple="false"
>
<span slot="noResult">No results found</span>
</multi-select>
</div>
</div>
<div class="form-group width75">
<label for="clientSelect" class="col-form-label required">Client</label>
<div class="imported input-styling width75" id="clientSelect">
<multi-select
#select="change"
#remove="deselect"
v-model="selectedClient"
placeholder="Select client"
:options="allClients"
>
<span slot="noResult">No results found</span>
</multi-select>
</div>
<p class="error" v-if="newClaimFormError.clientId">
This field is required
</p>
</div>
<div v-if="newClaimForm.selectedContract !== ''" class="form-group mt-4 width-50 position-relative">
<label for class="col-form-label required">Effective Date</label>
<i class="icon-calendar3 calender-icon" />
<date-picker
id="date"
placeholder="Select Effective Date"
wrapper-class="width75"
input-class="date-picker__input"
:value="effectiveDate"
#selected="formatDate"
#input="changeDateFormat"
v-model="effectiveDate"
ref="datepicker"
>
</date-picker>
<p
class="error"
v-if="newClaimFormError.effectiveDate"
>This field is required</p>
</div>
</div>
<div v-show="claimRelatedTo === 'Sales Team'" class="form-group">
<label for="saleTeamLeaderSelect" class="col-form-label required">Sales Team Leader</label>
<div class="imported input-styling width75" id="saleTeamLeaderSelect">
<multi-select
v-model="newClaimForm.selectedLeader"
placeholder="Select sales team leader"
:options="teamLeaderList"
:multiple="false"
:show-labels="false"
/>
</div>
</div>
</div>
</form>
I need the functionality like when I use tab keys to navigate over the datepicker field the calendar popup should open like it works on click of field. And when the popup opens I should be able to access the calendar dates years with tab key also.
Is there any way to do it?
I'm still quite new to web development, so there might be some very basic misunderstandings on my part.
What I'm trying to do:
We use Keycloak to manage access to a web app. The app is Vue project using Vuetify. To achieve a unified look, I want to use Vuetify to design the Keycloak theme for the login as well.
Here is the screendesign:
What I've done so far:
I created the folder keycloak/themes/my-theme, and added these files:
I took the two ftl files from the base theme, then I tried to rewrite the login with Vuetify classes.
To do so I inspected the code of the elements I want in the Vuetify docs and worked them into login.ftl. While this did work more or less for the Log In button, it seems to be completely wrong for the inputs.
Here is what it looks like:
The misalignment is probably fixable with a lot of fine tuning, but one thing I don't know what to do about is that the text inputs don't get activated when I click into them.
I'm pretty sure that copying code from the developer tools is the wrong way to do this. Is there any way to actually design a Keycloak theme with Vuetify? Without basically copying the Vuetify code?
Here is the current login.ftl:
<#import "template.ftl" as layout>
<#layout.registrationLayout displayInfo=social.displayInfo displayWide=(realm.password && social.providers??); section>
<#if section = "header">
${msg("loginWelcomeMessage")}
<#elseif section = "form">
<div id="kc-form" <#if realm.password && social.providers??>class="${properties.kcContentWrapperClass!}"</#if>>
<div id="kc-form-wrapper" <#if realm.password && social.providers??>class="${properties.kcFormSocialAccountContentClass!} ${properties.kcFormSocialAccountClass!}"</#if>>
<#if realm.password>
<form id="kc-form-login" onsubmit="login.disabled = true; return true;" action="${url.loginAction}" method="post">
<div class="${properties.kcFormGroupClass!}">
<div class="v-input rom__text--darkblue theme--light v-text-field v-text-field--is-booted v-text-field--enclosed v-text-field--outlined v-text-field--placeholder">
<div class="v-input__control">
<div class="v-input__slot">
<div class="v-input__prepend-inner">
<div class="v-input__icon v-input__icon--prepend-inner"><i aria-hidden="true" class="v-icon notranslate fas fa-user-circle theme--light"></i></div>
</div>
<fieldset aria-hidden="true">
<legend style="width: 188.25px;"><span></span></legend>
</fieldset>
<div class="v-text-field__slot">
<label for="username" class="v-label v-label--active" style="left: -28px; right: auto; position: absolute;">
${msg("usernameOrEmail")}
</label>
<#if usernameEditDisabled??>
<input tabindex="1" id="username" placeholder="Ihr Nutzername" type="text" value="${(login.username!'')}" type="text" disabled>
<#else>
<input tabindex="1" id="username" placeholder="Ihr Nutzername" type="text">
</#if>
</div>
</div>
<div class="v-text-field__details">
<div class="v-messages theme--light">
<div class="v-messages__wrapper"></div>
</div>
</div>
</div>
</div>
</div>
<div class="${properties.kcFormGroupClass!}">
<label for="password" class="${properties.kcLabelClass!}">${msg("password")}</label>
<input tabindex="2" id="password" class="${properties.kcInputClass!}" name="password" type="password" autocomplete="off" />
</div>
<div class="${properties.kcFormGroupClass!} ${properties.kcFormSettingClass!}">
<div id="kc-form-options">
<#if realm.rememberMe && !usernameEditDisabled??>
<div class="checkbox">
<label>
<#if login.rememberMe??>
<input tabindex="3" id="rememberMe" name="rememberMe" type="checkbox" checked> ${msg("rememberMe")}
<#else>
<input tabindex="3" id="rememberMe" name="rememberMe" type="checkbox"> ${msg("rememberMe")}
</#if>
</label>
</div>
</#if>
</div>
<div class="${properties.kcFormOptionsWrapperClass!}">
<#if realm.resetPasswordAllowed>
<span><a tabindex="5" href="${url.loginResetCredentialsUrl}">${msg("doForgotPassword")}</a></span>
</#if>
</div>
</div>
<div id="kc-form-buttons" class="${properties.kcFormGroupClass!} align-center justify-center">
<input type="hidden" id="id-hidden-input" name="credentialId" <#if auth.selectedCredential?has_content>value="${auth.selectedCredential}"</#if>/>
<button tabindex="4" name="login" id="kc-login" type="submit" class=" align-center justify-center v-btn rom__darkblue rom__text--white elevation-2 v-size--large">
<i class="v-icon v-icon--left fas fa-sign-in-alt"></i>
${msg("doLogIn")}
</button>
</div>
</form>
</#if>
</div>
<#if realm.password && social.providers??>
<div id="kc-social-providers" class="${properties.kcFormSocialAccountContentClass!} ${properties.kcFormSocialAccountClass!}">
<ul class="${properties.kcFormSocialAccountListClass!} <#if social.providers?size gt 4>${properties.kcFormSocialAccountDoubleListClass!}</#if>">
<#list social.providers as p>
<li class="${properties.kcFormSocialAccountListLinkClass!}"> <span>${p.displayName}</span></li>
</#list>
</ul>
</div>
</#if>
</div>
<#elseif section = "info" >
<#if realm.password && realm.registrationAllowed && !registrationDisabled??>
<div id="kc-registration">
<span>${msg("noAccount")} <a tabindex="6" href="${url.registrationUrl}">${msg("doRegister")}</a></span>
</div>
</#if>
</#if>
</#layout.registrationLayout>
It looks like you are using Vuetify styles only. I would try to use Vue with the top element:
new Vue({
el: "#kc-form",
vuetify: new Vuetify(),
...
And then I would create all inputs with Vuetify, e.g. username:
<v-text-field label="Username or email" id="username" />
But you need to mimic those original HTML inputs, so you need to add also some parameters, e.g. name - I would use mounted for that - naive implementation:
mounted() {
document.getElementById("username").setAttribute("name", "username")
}
It may need also changes in the layout template and more tweaks to have naive Vuetify feel and full Keycloak functionality. It will be nice if you share your results (even incomplete) on the GitHub.
Proof of concept: https://github.com/jangaraj/vuetify-keycloak-theme/ :
my html
<div v-for="(client, index) in clients" :key="index">
<div>
<span>{{index+1}} {{client.id}}</span>
</div>
<div>
<div>
<label>
<input type="checkbox" :checked="client.IsScreenShot"/>
<span class="slider"></span>
</label>
</div>
<div>
<label>
<input type="checkbox" :checked="client.IsPhotoReport" />
<span class="slider"></span>
</label>
</div>
<div>
<label>
<input type="checkbox" :checked="client.IsShowReport" />
<span class="slider"></span>
</label>
</div>
<button type="submit" #click.prevent="onChangeAccess(client)">Change</button>
</div>
</div>
I have multiple checkboxes in div thats coming from v-for and array of data.
Each checkbox is came from data and give true or false value to start position, thats represent value right now.
When user check or uncheck checkbox (it depends want he or not give to client right to see pages on site), I want to take new value from check box and send it to server.
How I can take this new value from each checkbox?
And this is array of div's with three checkboxes in each div, but I need at time only this specific change value from this specific div. I don't need to know if every value in multiple div change. I need to pass only this specific changes value from 1 this div.
For example at first user get 1 div with first input value true, second - false, third - true.
Then user change checkboxes to first input - false, second - true, third - true.
So when he clicked on button, I need to get value from first, second and third checkbox and pass it to method.
How I can get it? any idea please
Vue is perfect, so I find a great solution, hope it helps someone, I just little correct the code
<div v-for="(client, index) in clients" :key="index">
<div>
<span>{{index+1}} {{client.id}}</span>
</div>
<div>
<div>
<label>
<input type="checkbox" :checked="client.IsScreenShot" #click="client.IsScreenShot = !client.IsScreenShot"/>
<span class="slider"></span>
</label>
</div>
<div>
<label>
<input type="checkbox" :checked="client.IsPhotoReport" #click="client.IsPhotoReport = !client.IsPhotoReport"/>
<span class="slider"></span>
</label>
</div>
<div>
<label>
<input type="checkbox" :checked="client.IsShowReport" #click="client.IsShowReport = !client.IsShowReport"/>
<span class="slider"></span>
</label>
</div>
<button type="submit" #click.prevent="onChangeAccess(client)">Change</button>
</div>
</div>
God save Vue =)
I have the following form with name input field. I am trying to put validations on the field. When I print the name.className value it prints ng-valid, ng-pristine and other classes.
I want to use *ngIf to display the error message but it is not working.
I tried *ngIf="name.ng-invalid" also but it is not working. Can anyone suggest what is wrong here?
<form class="form-horizontal div-table" >
<!-- Name -->
<div class="form-group row-even">
<label class="col-md-4 control-label">Name:</label>
<div class="col-md-7">
<input id="name" name="name" type="text" class="form-control" [(ngModel)]="data.name" required minlength="3" maxlength="64" #name>
<small *ngIf="name.ng-invalid">
Name is required (minimum 3 characters).
</small>
<small>
Element {{ name.className }}
</small>
</div>
</div>
</form>
Try setting #name="ngModel" on the input.
Then remove "ng" from
<small *ngIf="name.ng-invalid">
like so
<small *ngIf="name.invalid">
Try this code
<form (ngSubmit)="onSubmit()" #myForm="ngForm">
...
<div [hidden]="name.valid || name.pristine"
class="alert alert-danger">
Name is required
</div>
...
</form>