TypiCMS / Base

Multilingual CMS built with Laravel.
MIT License
1.4k stars 404 forks source link

Not checked checkbox in ItemListStatusButton and ItemListTree #271

Open GreenBabyBorn opened 1 year ago

GreenBabyBorn commented 1 year ago

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';
            }
        },
sdebacker commented 1 year ago

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

GreenBabyBorn commented 1 year ago

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