mirror of
https://github.com/wallabag/wallabag.git
synced 2025-03-13 22:52:39 +00:00
Extract Leftbar and Add Tag controllers
This commit is contained in:
parent
ead400e6c2
commit
75618c0806
5 changed files with 24 additions and 13 deletions
13
assets/controllers/add_tag_controller.js
Normal file
13
assets/controllers/add_tag_controller.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
import { Controller } from '@hotwired/stimulus';
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ['input'];
|
||||
|
||||
toggle() {
|
||||
this.element.classList.toggle('hidden');
|
||||
|
||||
if (!this.element.classList.contains('hidden')) {
|
||||
this.inputTarget.focus();
|
||||
}
|
||||
}
|
||||
}
|
7
assets/controllers/leftbar_controller.js
Normal file
7
assets/controllers/leftbar_controller.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
import { Controller } from '@hotwired/stimulus';
|
||||
|
||||
export default class extends Controller {
|
||||
toggleAddTagForm() {
|
||||
this.dispatch('toggleAddTagForm');
|
||||
}
|
||||
}
|
|
@ -128,12 +128,3 @@ import './scss/index.scss';
|
|||
preferedColorScheme.init();
|
||||
addDarkThemeListeners();
|
||||
}());
|
||||
|
||||
$(document).ready(() => {
|
||||
$('#nav-btn-add-tag').on('click', () => {
|
||||
$('.nav-panel-add-tag').toggle();
|
||||
$('.nav-panel-menu').addClass('hidden');
|
||||
$('#tag_label').focus();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
<ul id="slide-out" class="left-bar collapsible sidenav sidenav-fixed reader-mode" data-controller="materialize--sidenav materialize--collapsible">
|
||||
<ul id="slide-out" class="left-bar collapsible sidenav sidenav-fixed reader-mode" data-controller="materialize--sidenav materialize--collapsible leftbar">
|
||||
<li class="bold border-bottom hide-on-med-and-down">
|
||||
<a class="waves-effect collapsible-header" href="{{ path('homepage') }}">
|
||||
<i class="material-icons small">arrow_back</i>
|
||||
|
@ -105,7 +105,7 @@
|
|||
{% endif %}
|
||||
|
||||
<li class="bold border-bottom">
|
||||
<a class="waves-effect collapsible-header" id="nav-btn-add-tag" data-action="click->materialize--sidenav#close">
|
||||
<a class="waves-effect collapsible-header" id="nav-btn-add-tag" data-action="click->materialize--sidenav#close click->leftbar#toggleAddTagForm">
|
||||
<i class="material-icons small">label_outline</i>
|
||||
<span>{{ 'entry.view.left_menu.add_a_tag'|trans }}</span>
|
||||
</a>
|
||||
|
@ -317,7 +317,7 @@
|
|||
{% include "Entry/_tags.html.twig" with {'tags': entry.tags, 'entryId': entry.id, 'withRemove': true} only %}
|
||||
</div>
|
||||
|
||||
<div class="input-field nav-panel-add-tag" style="display: none">
|
||||
<div class="input-field nav-panel-add-tag hidden" data-controller="add-tag" data-action="leftbar:toggleAddTagForm@window->add-tag#toggle">
|
||||
{{ render(controller('Wallabag\\Controller\\TagController::addTagFormAction', {'id': entry.id})) }}
|
||||
</div>
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<span class="black-text">{{ form_errors(form.label) }}</span>
|
||||
{% endif %}
|
||||
|
||||
{{ form_widget(form.label, {'attr': {'autocomplete': 'off'}}) }}
|
||||
{{ form_widget(form.label, {'attr': {'autocomplete': 'off', 'data-add-tag-target': 'input'}}) }}
|
||||
|
||||
{{ form_widget(form.add, {'attr': {'class': 'btn waves-effect waves-light tags-add-form-submit'}}) }}
|
||||
{{ form_widget(form._token) }}
|
||||
|
|
Loading…
Reference in a new issue