Author: Hugo Melo <hugo@riseup.net>
Add hub filter to consumers page
plugins/suppliers/locales/en-US.yml | 4 plugins/suppliers/locales/pt-BR.yml | 8 plugins/suppliers/public/javascripts/views/consumer-page.tag.slim | 36 plugins/suppliers/public/stylesheets/consumer.scss | 62
diff --git a/plugins/suppliers/locales/en-US.yml b/plugins/suppliers/locales/en-US.yml index c4374bc90fa45cf6ea66f4e5e880ea22272c4ce7..7a22f69599ad53c9d42e2f8983127c3f125ee9f5 100644 --- a/plugins/suppliers/locales/en-US.yml +++ b/plugins/suppliers/locales/en-US.yml @@ -196,7 +196,7 @@ saved: "Saved!" close: "close" stock_modal: "Inventory movimentation" action: "Action" - quantity: "Quantity" + quantity: "Quantity" description: "description" the_description: "Describe the movimentation. Ex: remotion of 2 boxes to distribution" adition: adition @@ -462,6 +462,8 @@ cancel: Cancel rejection_message: "Please, explanain why you are rejecting this membership request" inactive: inactive active: active + filter: Filter + select_hub: Select a hub orders_cycle_plugin: terms: diff --git a/plugins/suppliers/locales/pt-BR.yml b/plugins/suppliers/locales/pt-BR.yml index bdd4746469722c06a25130225728ec62aaf4180a..991afced34d74f002df7ee16fb042006c058bbe1 100644 --- a/plugins/suppliers/locales/pt-BR.yml +++ b/plugins/suppliers/locales/pt-BR.yml @@ -202,7 +202,7 @@ saved: "Salvo!" close: "Fechar" stock_modal: "Movimentação de Estoque" action: "Ação" - quantity: "Quantidade" + quantity: "Quantidade" description: "Descrição" the_description: "Descreva a movimentação. Ex: Saída de 2 caixas para distribuição" adition: "adição" @@ -470,8 +470,8 @@ remove: Remover do grupo confirm_remove: "Você tem certeza de que quer remover '%{consumer}' do grupo?" disable: Desabilitar consumidor enable: Habilitar consumidor - confirm_disable: "Você tem certeza de que quer desabilitar '%{consumer}' de fazer pedidos no grupo?" - confirm_enable: "Você tem certeza de que quer reabilitar '%{consumer}' a fazer pedidos no grupo?" + confirm_disable: "Você tem certeza de que quer desabilitar '%{consumer}' de fazer pedidos no grupo?" + confirm_enable: "Você tem certeza de que quer reabilitar '%{consumer}' a fazer pedidos no grupo?" tasks: "<strong>%{people} pessoas</strong> aguardam aprovação para entrar no grupo" manage: "Gerenciar" saved: "Salvo!" @@ -486,6 +486,8 @@ cancel: Cancelar rejection_message: "Por favor, explique por que você está rejeitando o pedido de filiação desse membro ao grupo." inactive: inativo active: ativo + filter: Filtro + select_hub: Selecione um núcleo orders_cycle_plugin: terms: diff --git a/plugins/suppliers/public/javascripts/views/consumer-page.tag.slim b/plugins/suppliers/public/javascripts/views/consumer-page.tag.slim index 595df7418533f718faaacc4aaf61133e9b239259..2f83cd8bce0fecb02c7418d2e74b4702a0a7635f 100644 --- a/plugins/suppliers/public/javascripts/views/consumer-page.tag.slim +++ b/plugins/suppliers/public/javascripts/views/consumer-page.tag.slim @@ -26,10 +26,23 @@ .col-xs-12 .pending-consumers.consumers-listing.row pending-consumer-box each='{consumer in pendingConsumers}' consumer='{consumer}' - .row - .search.col-xs-12 - input name='search' placeholder="{cs.t('views.consumer.index.search')}" onkeyup='{search}' - .search-icon + .filter + input type='hidden' value="{page}" + + h4 + |{cs.t("views.consumer.index.filter")} + form.form-inline onsubmit="return false" + .form-group + .name + input name='search' placeholder="{cs.t('views.consumer.index.search')}" onkeyup='{search}' + + .form-group.hub_id + select name="hub_id" onchange="{search}" + option value="" + |{cs.t("views.consumer.index.select_hub")} + option each="{hub in hubs}" value="{hub.id}" selected="{hub.id == filter_hub_id}" + |{hub.name} + .consumers-listing.row consumer-box each='{consumer in consumers}' consumer='{consumer}' @@ -45,16 +58,23 @@ this.hubs = opts.hubs; this.tasks = opts.tasks; this.editView = this.tags['consumer-view'] this.tasks_count = opts.tasks_count + this.filter_hub_id = opts.filter_hub_id var self = this; search(e) { var needle = removeDiacritics($('input[name="search"]').val().toLowerCase()) for (var i in this.consumers) { - var c = this.consumers[i] - var field1 = removeDiacritics(c.name.toLowerCase()) - var field2 = c.email || '' - this.consumers[i].selected = field1.indexOf(needle) > -1 || field2.indexOf(needle) > -1 + if (needle) { + var field1 = removeDiacritics(this.consumers[i].name.toLowerCase()) + var field2 = this.consumers[i].email || '' + this.consumers[i].selected = field1.indexOf(needle) > -1 || field2.indexOf(needle) > -1 + } else this.consumers[i].selected = true; + // filter hub + hub_id = $(".filter select[name=hub_id").val() + if (hub_id && this.consumers[i].selected && this.consumers[i].hub_id != hub_id) { + this.consumers[i].selected = false + } } } diff --git a/plugins/suppliers/public/stylesheets/consumer.scss b/plugins/suppliers/public/stylesheets/consumer.scss index e602230349152534c50be2c2b42f123396eaeb58..a4fdd0e092d2892b7a62b7c911af9de61853ec0a 100644 --- a/plugins/suppliers/public/stylesheets/consumer.scss +++ b/plugins/suppliers/public/stylesheets/consumer.scss @@ -3,8 +3,8 @@ .left { float: left; } #content { .box-container-1 { - background-color: #EFEFEF; - .main-block { background-color: #EFEFEF; } + background-color: white; + .main-block { background-color: white; } } .main-block .consumers-page { @@ -22,47 +22,61 @@ background-repeat: no-repeat; background-size: 27px auto; } - .search { - margin-top: 30px; + .filter { + width: 100%; + padding: 10px; + margin: 20px auto; + display: inline-block; + background-color: #f8f8f8; + border: 1px solid #efefef; + + h4 { + font-size: 13px; + font-weight: bold; + float: left; + margin-right: 20px; + } ::-webkit-input-placeholder { /* WebKit, Blink, Edge */ - color: $cirandas-header-bg; + color: #bababa; font-weight: bold; } :-moz-placeholder { /* Mozilla Firefox 4 to 18 */ - color: $cirandas-header-bg; + color: #bababa; font-weight: bold; opacity: 1; } ::-moz-placeholder { /* Mozilla Firefox 19+ */ - color: $cirandas-header-bg; + color: #bababa; font-weight: bold; opacity: 1; } :-ms-input-placeholder { /* Internet Explorer 10-11 */ - color: $cirandas-header-bg; + color: #bababa; font-weight: bold; } + + select { + background-color: #f8f8f8; + margin-left: 15px; + max-width: 300px; + } + + .form-group { + width: 30%; + } input { border: none; - border-bottom: 2px solid $cirandas-header-bg; background-color: transparent; - color: $cirandas-header-bg; outline: none; - margin-bottom: 10px; font-size: 16px; width: 100%; - margin-bottom: 15px; } - .search-icon { - width: 25px; - height: 25px; - background-image: url(/plugins/consumers_coop/images/pesquisa.png); - background-repeat: no-repeat; - background-size: 24px auto; - position: absolute; - top: -2px; - right: 16px; + input, select { + @include input; + } + input,select { + background-color: white; } } .picture-block { @@ -105,7 +119,7 @@ display: block; border: 2px solid $cirandas-header-bg; background-color: transparent; - color: #777; + color: #777; font-size: 14px; font-weight: bold; text-transform: uppercase; @@ -127,12 +141,12 @@ .right { float: right; } .consumer-box { &.inactive { - background-color: #e0e0e0; + background-color: #FAFAFA; .name-block { .state { color: red; } } } - background-color: white; + background-color: #F0F0F0; &:hover { background-color: #DBE2E1; }