Skip to content

Commit

Permalink
Merge branch 'v5/develop' into v6/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
distantnative committed Jan 15, 2025
2 parents c65e07d + 3bc69f4 commit 4b47d29
Show file tree
Hide file tree
Showing 27 changed files with 505 additions and 244 deletions.
3 changes: 1 addition & 2 deletions config/areas/languages/views.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@
],
'props' => [
'buttons' => fn () =>
ViewButtons::view('language')
ViewButtons::view('language', model: $language)
->defaults('preview', 'settings', 'delete')
->bind(['language' => $language])
->render(),
'deletable' => $language->isDeletable(),
'code' => Escape::html($language->code()),
Expand Down
2 changes: 1 addition & 1 deletion config/fields/number.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
],
'methods' => [
'toNumber' => function ($value) {
if ($this->isEmpty($value) === true) {
if ($this->isEmptyValue($value) === true) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion config/fields/toggle.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
'required' => function ($value) {
if (
$this->isRequired() &&
($value === false || $this->isEmpty($value))
($value === false || $this->isEmptyValue($value))
) {
throw new InvalidArgumentException(
message: I18n::translate('field.required')
Expand Down
4 changes: 2 additions & 2 deletions panel/src/components/Forms/Blocks/BlockOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@ export default {
this.$refs.options.open();
},
sort(event) {
event.preventDefault();
switch (event.key) {
case "ArrowUp":
event.preventDefault();
this.$emit("sortUp");
break;
case "ArrowDown":
event.preventDefault();
this.$emit("sortDown");
break;
}
Expand Down
93 changes: 52 additions & 41 deletions panel/src/components/Forms/Field/StructureField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
:rows="paginatedItems"
:sortable="isSortable"
@cell="open($event.row, $event.columnIndex)"
@input="save"
@input="onTableInput"
@option="option"
@paginate="paginate"
/>
Expand Down Expand Up @@ -171,21 +171,6 @@ export default {
return (this.page - 1) * this.limit + 1;
},
/**
* Returns if new entries can be added
* @returns {bool}
*/
more() {
if (this.disabled === true) {
return false;
}
if (this.max && this.items.length >= this.max) {
return false;
}
return true;
},
hasFields() {
return this.$helper.object.length(this.fields) > 0;
},
Expand Down Expand Up @@ -216,6 +201,21 @@ export default {
return true;
},
/**
* Returns if new entries can be added
* @returns {bool}
*/
more() {
if (this.disabled === true) {
return false;
}
if (this.max && this.items.length >= this.max) {
return false;
}
return true;
},
/**
* Returns config for `k-pagination`
* @returns {Obect}
Expand Down Expand Up @@ -245,31 +245,25 @@ export default {
return [];
}
let options = [];
let more = this.duplicate && this.more;
options.push({
icon: "edit",
text: this.$t("edit"),
click: "edit"
});
options.push({
disabled: !more,
icon: "copy",
text: this.$t("duplicate"),
click: "duplicate"
});
options.push("-");
options.push({
icon: "trash",
text: more ? this.$t("delete") : null,
click: "remove"
});
return options;
return [
{
icon: "edit",
text: this.$t("edit"),
click: "edit"
},
{
disabled: !this.duplicate || !this.more,
icon: "copy",
text: this.$t("duplicate"),
click: "duplicate"
},
"-",
{
icon: "trash",
text: this.$t("delete"),
click: "remove"
}
];
},
/**
* Returns paginated slice of items/rows
Expand Down Expand Up @@ -443,6 +437,23 @@ export default {
}
},
/**
* Merges the updated values from the paginated table
* into the original items array and saves them
* @param {Array} values
*/
onTableInput(values) {
if (this.limit) {
values = this.items.toSpliced(
this.pagination.offset,
this.limit,
...values
);
}
this.save(values);
},
/**
* Update pagination state
* @param {Object} pagination
Expand Down
20 changes: 10 additions & 10 deletions panel/src/components/Forms/Writer/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,16 +413,6 @@ export default class Editor extends Emitter {
}
}

isEditable() {
return this.options.editable;
}

isEmpty() {
if (this.state) {
return this.state.doc.textContent.length === 0;
}
}

get isActive() {
return Object.entries({
...this.activeMarks,
Expand All @@ -436,6 +426,16 @@ export default class Editor extends Emitter {
);
}

isEditable() {
return this.options.editable;
}

isEmpty() {
if (this.state) {
return this.state.doc.textContent.length === 0;
}
}

removeMark(mark) {
if (this.schema.marks[mark]) {
return utils.removeMark(this.schema.marks[mark])(
Expand Down
2 changes: 1 addition & 1 deletion panel/src/components/Forms/Writer/Extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default class Extensions {
buttons[button.id ?? button.name] = button;
}
} else {
buttons[extension.name] = extension.button;
buttons[extension.name] = { name: extension.name, ...extension.button };
}
}

Expand Down
Loading

0 comments on commit 4b47d29

Please sign in to comment.