TypiCMS/Base

Not checked checkbox in ItemListStatusButton and ItemListTree

GreenBabyBorn opened this issue · 2 comments

Checkboxes are not checked when the page loads, although they should.
The problem was in a non-strict condition
Solution for ItemListTree.vue:

<button class="btn-status me-2" type="button" @click="toggleStatus(node)">
  <span v-if="translatable" :class="node.data.status_translated == 1 ? 'btn-status-icon-on' : 'btn-status-icon-off'" class="btn-status-icon"></span>
  <span v-else :class="node.data.status == 1 ? 'btn-status-icon-on' : 'btn-status-icon-off'" class="btn-status-icon"></span>
</button>

Solution for ItemListStatusButton.vue:

statusOn() {
            if (typeof this.model.status_translated === 'undefined') {
                return parseInt(this.model.status) == '1';
            } else {
                return this.model.status_translated == '1';
            }
        },

I need more info to correctly understand what you mean here.

I need more info to correctly understand what you mean here.

For example, when I open the "/admin/pages" page, each page has a checkbox that shows whether the page is published or not. By default, all pages are published and when the page loads, the checkboxes should be active, but they are not active. This is due to the fact that a strict comparison was used in the component
checkbox.webm