att
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
application.type=widget
|
||||
application.code=filtrosDash
|
||||
application.title=filtrosDash
|
||||
application.description=filtrosDash
|
||||
application.fluig.version=null
|
||||
application.category=SYSTEM
|
||||
application.renderer=freemarker
|
||||
developer.code=andrey.cunha
|
||||
developer.name=andrey.cunha
|
||||
developer.url=http://www.fluig.com
|
||||
application.uiwidget=true
|
||||
application.mobileapp=false
|
||||
application.version=${build.version}-${build.revision}
|
||||
view.file=view.ftl
|
||||
edit.file=edit.ftl
|
||||
locale.file.base.name=filtrosDash
|
||||
application.resource.js.1=/resources/js/filtrosDash.js
|
||||
application.resource.css.2=/resources/css/filtrosDash.css
|
||||
hash=4a16315e9e66fa7d797b3f6b1fb365b69f9a4ce2
|
||||
@@ -0,0 +1,4 @@
|
||||
<div id="MyWidget_${instanceId}" class="super-widget wcm-widget-class fluig-style-guide" data-params="MyWidget.instance()">
|
||||
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<div id="filtroDash_${instanceId}"
|
||||
class="super-widget wcm-widget-class fluig-style-guide"
|
||||
data-params="FiltroDash.instance()">
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-3">
|
||||
<label>Data início</label>
|
||||
<input type="date" class="form-control" id="dtInicio_${instanceId}">
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<label>Data fim</label>
|
||||
<input type="date" class="form-control" id="dtFim_${instanceId}">
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<label>Filial</label>
|
||||
<input class="form-control" id="filial_${instanceId}" list="filial_list_${instanceId}" placeholder="Todas">
|
||||
<datalist id="filial_list_${instanceId}">
|
||||
<option value="Todas"></option>
|
||||
</datalist>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
<label> </label>
|
||||
<button type="button" class="btn btn-primary btn-block" data-filtrar>
|
||||
Filtrar
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jboss-web>
|
||||
<context-root>/filtrosDash</context-root>
|
||||
<disable-cross-context>false</disable-cross-context>
|
||||
</jboss-web>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
||||
version="3.0">
|
||||
<session-config>
|
||||
<session-timeout>
|
||||
30
|
||||
</session-timeout>
|
||||
</session-config>
|
||||
</web-app>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
div[id^="filtroDash_"] input[list] {
|
||||
padding-right: 30px;
|
||||
}
|
||||
|
||||
div[id^="filtroDash_"] .btn[data-filtrar] {
|
||||
font-weight: 600;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 7.7 KiB |
+111
@@ -0,0 +1,111 @@
|
||||
var FiltroDash = SuperWidget.extend({
|
||||
|
||||
lojasCarregadas:[],
|
||||
|
||||
init: function(){
|
||||
|
||||
console.log("FiltroDash carregado");
|
||||
|
||||
this.carregarLojas();
|
||||
|
||||
},
|
||||
|
||||
bindings: {
|
||||
local:{
|
||||
'filtrar': ['click_filtrar']
|
||||
}
|
||||
},
|
||||
|
||||
carregarLojas: function(){
|
||||
|
||||
var self = this;
|
||||
var dataList = $("#filial_list_"+this.instanceId);
|
||||
|
||||
$.ajax({
|
||||
|
||||
url: "/api/public/ecm/dataset/search",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
|
||||
data: JSON.stringify({
|
||||
datasetId: "ds_lojas_api",
|
||||
constraints: [],
|
||||
fields: [],
|
||||
order: []
|
||||
}),
|
||||
|
||||
success: function(response){
|
||||
|
||||
var dados = response.content || [];
|
||||
self.lojasCarregadas = dados.map(function(loja){
|
||||
return String(loja.LOJA || "").trim();
|
||||
}).filter(function(v){ return !!v; });
|
||||
|
||||
self.lojasCarregadas.sort(function(a,b){
|
||||
return a.localeCompare(b);
|
||||
});
|
||||
|
||||
self.lojasCarregadas.forEach(function(loja){
|
||||
|
||||
dataList.append(
|
||||
'<option value="'+loja+'"></option>'
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
filtrar:function(){
|
||||
|
||||
console.log("Filtrar clicado");
|
||||
|
||||
var lojaDigitada = String($("#filial_"+this.instanceId).val() || "").trim();
|
||||
|
||||
var filtros = {
|
||||
|
||||
dataInicio: $("#dtInicio_"+this.instanceId).val(),
|
||||
dataFim: $("#dtFim_"+this.instanceId).val(),
|
||||
loja: this.resolverLoja(lojaDigitada)
|
||||
|
||||
};
|
||||
|
||||
console.log("Filtros enviados:", filtros);
|
||||
|
||||
window.dispatchEvent(
|
||||
new CustomEvent("dashboardFiltro",{detail:filtros})
|
||||
);
|
||||
|
||||
},
|
||||
|
||||
resolverLoja:function(lojaDigitada){
|
||||
if(!lojaDigitada){
|
||||
return "";
|
||||
}
|
||||
|
||||
var buscado = lojaDigitada.toUpperCase();
|
||||
if(buscado === "TODAS" || buscado === "TODOS"){
|
||||
return "";
|
||||
}
|
||||
var lojas = this.lojasCarregadas || [];
|
||||
|
||||
for(var i=0;i<lojas.length;i++){
|
||||
if(lojas[i].toUpperCase() === buscado){
|
||||
return lojas[i];
|
||||
}
|
||||
}
|
||||
|
||||
for(var j=0;j<lojas.length;j++){
|
||||
if(lojas[j].toUpperCase().indexOf(buscado) >= 0){
|
||||
return lojas[j];
|
||||
}
|
||||
}
|
||||
|
||||
return lojaDigitada;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
Binary file not shown.
Reference in New Issue
Block a user