Add actionbutton in a dropdown menu , how do I know if the button was clicked in shiny - shinydashboard

Like to know if a button was clicked or how integrate the actionButton of shiny need to know if a option was selected then used to run something
New using shiny, just want to do a easy dashboard
library(shiny)
library(bs4Dash)
ui <-
bs4DashPage(
enable_preloader = TRUE,
navbar = bs4DashNavbar(border = FALSE,
rightUi = HTML('<div class="dropdown">
<button class = "btn btn-outline-primary dropdown-toggle"
type = "button"
id = "dropdownMenuButton"
data-toggle ="dropdown"
aria-haspopup="true"
aria-expanded="false">
Período de Consulta
</button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuButton">
<button id = "yr_anterior" class="dropdown-item" type="button">Año Pasado</button>
<button id = "mes_anterior" class="dropdown-item" type="button">Mes Pasado</button>
<button id = "sem_anterior" class="dropdown-item" type="button">Ultima Semana</button>
</div>
</div>')),
sidebar = bs4DashSidebar(title = "Opciones",skin = "light",status = "info",brandColor = "primary"),
footer = bs4DashFooter(),
title = "test",
body = bs4DashBody(
textOutput("valor")
)
)
server <- function(input, output,session) {
observeEvent(input$yr_anterior,{
output$valor <- renderText("hola")})
}
# Run the application
shinyApp(ui = ui, server = server)

I think the function pickerInput from shinyWidgets package can generate what you are looking for. You can use it like this with the labels in your example, and input$InputMenu gives the selected option on your server function
pickerInput(inputId = 'InputMenu',
choices = c("Período de Consulta","Año Pasado","Mes Pasado","Ultima Semana"),
options = list(style = "btn-outline-primary dropdown-toggle") )
or adding a label instead of that first choice label="Período de Consulta:"

Related

Select Option (for dropdown) Laravel

I make a dropdown for a form, I will show the code below. However, when I click the submit button, there is an error saying,
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'brand' cannot be null (SQL: insert into supplier_details.
The data that I chose from the dropdown is actually null. Actually, I'm new to Laravel.
I don't want to make a dropdown list from a database, I just want to display the option and the option will be inserted into the database when the user clicks the submit button after filling in the form.
<div class="form-group row">
<label style="font-size: 16px;" for="id" class = "col-sm-2">Item Brand </label>
<label for="supp_name" class = "col-sm-1">:</label>
<div class="col-sm-7">
<select name="brand" class="form-control js-example-basic-single" required>
<option >Please select item brand</option>
<option value="machine1"> Item Brand 1 </option>
<option value="machine1"> Item Brand 2 </option>
<option value="machine1"> Tem Brand 3 </option>
</select>
</div>
</div>
Controller
public function createsupplierdetails()
{
return view ('frontend.praiBarcode.getweight');
}
public function supplierdetails(Request $r)
{
$details = new SupplierDetail;
$getuserPO = Supplier::where('PO',$r->PO)->first();
$details->brand = $getuserPO->brand;
$details->container_no = $getuserPO->container_no;
$details->date_received = $getuserPO->date_received;
$details->gross_weight = $getuserPO->gross_weight;
$details->tare_weight = $getuserPO->tare_weight;
$details->net_weight = $getuserPO->net_weight;
$details->save();
return view ('frontend.praiBarcode.viewsupplierdetails')
->with('details',$details);
}
This to check to verify if it is working:
Make sure you are submitting the correct form.
Try doing dd on your controller dd($request->all())
If data is reaching the controller and not inserted into the database, check on your model, if it is added to fillable or if there is only id in the guarded array. You can know about more here in https://laravel.com/docs/9.x/eloquent#mass-assignment
Error should be fixed, as soon as you fix it.
Controller
use Validator;
public function store(Request $request)
{
$validator = Validator::make($request->all(), [
'brand' => 'required',
]);
if ($validator->fails()) {
return redirect()->back()->with('error', $validator->errors()->first());
}
$details = new SupplierDetail();
$details->brand = $request->brand;
$details->container_no = $request->container_no;
$details->date_received = $request->date_received;
$details->gross_weight = $request->gross_weight;
$details->tare_weight = $request->tare_weight;
$details->net_weight = $request->net_weight;
$details->save();
if ($trending) {
return redirect(route('details.index'))->with('success', 'Field added successfully');
} else {
return redirect()->back()->with('error', 'Field has been not added successfully');
}
}

VueJS unexpectedly runs a function

Hello guys specially VueJS devs theres something weird happened. Ill explain it one by one
Full video:
https://drive.google.com/file/d/1G2ksQsMQ1LB868dg29f8mm4NR_x5GycF/view?fbclid=IwAR1YmYbo3J6jHrY6PHd8E_lxA47VJSXV6G3132_uF6Or3bXv7MbnQbRvKaU
I use datatable and then i use this getDefaultPrice() to manipulate the price because the format of my price is like this ("65;75") to return the first value to PHP 65.00
then once i click the add to cart button please see image for codes the getDefaultPrice() also executed.
and I received an error "price.split is not a function" I tried to console.log the function and it really runs it without calling it in my add_to_cart();
<td>
<p>{{getDefaultPrice(product.price)}}</p>
</td>
<td>
<button
class="btn main_bg_color add_to_cart_btn" data-toggle="modal" data-target="#productModal"
#click="add_to_cart(product)"
>
<i class="fa fa-shopping-cart"></i> Add to cart
</button>
</td>
add_to_cart(product) {
this.modal_data = [];
this.modal_data.push(product)
this.modal_data[0].variation = this.modal_data[0].variation.split(';');
this.modal_data[0].price = this.modal_data[0].price.split(';');
this.modal_data[0].drinks_price = this.modal_data[0].drinks_price.split(';');
this.modal_data[0].drinks = this.modal_data[0].drinks.split(';');
},
getDefaultPrice(price) {
console.log("test")
var price_arr = price.split(";");
var default_price = parseFloat(price_arr[0]);
return "PHP " + default_price.toFixed(2);
},

How do i call the controller from a new folder in mvc4

How do i call a controller from anchor tag when Controller is on the:
Area->Ticket->TicketController
Here is the code:
<a href="#Url.Action("TicketTemplate", "MyTickets", new {area = string.Empty,controller = "TicketTemplate", page = Model.PageNumber, sort = "DateCreated ", isAsc = isAsc })">
Date Created
<span class="#clsDateCreated" style="text-align: right;"></span>
</a>
The above code is not working..
How do i call the controller??
Here is the path:
~/Areas/Ticket/Controllers/TicketTemplateController.cs
You can do that and it will work, but i don't know if there is a better solution or not.
<a href="#Url.Action("MyTickets", "Ticket/TicketTemplate", , new {area = string.Empty,controller = "TicketTemplate", page = Model.PageNumber, sort = "DateCreated ", isAsc = isAsc })">
Date Created
<span class="#clsDateCreated" style="text-align: right;"></span>
</a>

dynamicly build <div> with razor vb.net

Hi i want to dynamicly build a div layout depending on the data i send to view, i want make 2 rows of divs and when there is odd number of models sent to view i want the layout to close as you can see in the code every 2nd model or on last model and start div every odd model .... but when i uncomment the commented code there are errors ....
(if i am not mistaken something similar worked in with C# so i hope it's only synax error)
#For Each procesData In Model
curElement = curElement + 1
elemNumb = elemNumb + 1
If (curElement = 1) Then
'#<div id="row"> !Comented
End If
#<h3>Element number #elemNumb</h3>
#<h3>#procesData.Name</h3>
#<h3>#procesData.Status.ToString</h3>
#<br />
If (curElement = Model.Count) Then
If (elemNumb = 1) Then
'#</div> !comented
End If
End If
If (curElement = 2) Then
'#</div> !comented
elemNumb = 0
End If
Next
I tweaked .css file and i managed to 'avoid' my problem but if anyone knows how to solve this without bypassing the original problem i would be greatfull for answer :)
<div id="toggle">
#For Each procesData In Model
curElement = curElement + 1
elemNumb = elemNumb + 1
Dim idName As String = "element" + elemNumb.ToString
#<div id=#idName>
<div class="heading">
#procesData.Name ::::::: Status <img class="statusIMG" id=#procesData.Status.ToString align="right" src="/" />
</div>
<div class="content">
<p>
Dokladniejsze informacje o wskazniku (potrzebne bedzie id zeby wygenerowac partial view! zapamietac)
<br />
np.Html.ActionLink("Edit Me", "Edit", new { id=item.ID })
</p>
</div>
</div>
If (curElement = 2) Then
elemNumb = 0
End If
Next
</div>

Get title, nav_title and subtitle

I want to print the fields title, nav_title and subtitle with Typoscript. I saw that there are several possibilities. E.g. data, field, levelfield, leveltitle, ...
Currently I'm using this code (because the only one which works for me so far):
lib.heading = TEXT
lib.heading.dataWrap = <p class="title"> {leveltitle:0} </p>
but I want something with alternatives like this
stdWrap.field = subtitle // nav_title // title
What is the correct way of retrieving these fields?
Edit:
[userFunc = user_isMobile]
page.headerData.10 = TEXT
page.headerData.10.value (
// ...
)
// ...
lib.heading = TEXT
#lib.heading.dataWrap = <p class="title"> {leveltitle:0} </p>
lib.heading {
field = title
wrap = <p class="title"> | </p>
}
lib.subpages = HMENU
lib.subpages {
// ...
}
[global]
The userfunction itself is a function in a php script (user_mobile.php). It makes a user agent detection for mobile devices and returns true or false.
field will get values from the current data which in your context is the data of the current page.
lib.heading = TEXT
lib.heading {
field = subtitle // nav_title // title
wrap = <p class="title">|</p>
}
leveltitle, leveluid, levelmedia, etc. allow you to retrieve some of the data from other pages in the rootline of the current page.
For more information see getText in the documentation.