Skip to content

Commit

Permalink
Fix JS error when trying to replace a tag
Browse files Browse the repository at this point in the history
Fixes #13

Also:
- Improved some UI elements to better fit with Craft 3.4
- Added automatic slug generation when creating a tag
  • Loading branch information
Tam committed Apr 15, 2020
1 parent 8f57073 commit ce4155b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 1.0.7 - 2020-04-15
### Improved
- Improved some UI elements to better fit with Craft 3.4
- Added automatic slug generation when creating a tag

### Fixed
- Fix JS error when trying to replace a tag (Fixes #13)

## 1.0.6 - 2020-01-15
### Fixed
- Fix issue with pgsql when usage column is enabled
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ether/tags",
"description": "A tag manager for Craft 3",
"type": "craft-plugin",
"version": "1.0.6",
"version": "1.0.7",
"keywords": [
"craft",
"cms",
Expand Down
25 changes: 22 additions & 3 deletions src/templates/_edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@
</li>
{% endif %}
</ul>
{% if tag.id %}
<hr>
<ul>
<li>
<a id="delete-btn" class="error">
{{ 'Delete'|t('app') }}
</a>
</li>
</ul>
{% endif %}
</div>
</div>
{% endblock %}
Expand Down Expand Up @@ -105,7 +115,7 @@

{% block details %}
<div id="settings" class="meta">
{% if tag.id %}
{#{% if tag.id %}
<div class="first">
<div class="value flex">
<div class="flex-grow"></div>
Expand All @@ -123,7 +133,7 @@
</div>
</div>
</div>
{% endif %}
{% endif %}#}

{{ forms.textField({
label: 'Slug'|t('app'),
Expand All @@ -134,7 +144,8 @@
autocapitalize: false,
value: tag.slug,
placeholder: 'Enter slug'|t('app'),
errors: (tag.getErrors('slug')|merge(tag.getErrors('uri')))
errors: (tag.getErrors('slug')|merge(tag.getErrors('uri'))),
first: true
}) }}
</div>

Expand All @@ -151,3 +162,11 @@
</div>
{% endif %}
{% endblock %}

{% if not tag.slug %}
{% js %}
window.slugGenerator = new Craft.SlugGenerator('#title', '#slug', {
charMap: {{ craft.cp.getAsciiCharMap(tag.site.language)|json_encode|raw }}
});
{% endjs %}
{% endif %}
2 changes: 1 addition & 1 deletion src/web/assets/TagIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Craft.TagsIndex = Craft.BaseElementIndex.extend({
for (let i = 0, l = this.editableGroups.length; i < l; ++i) {
let group = this.editableGroups[i];

if (isIndex || group.id !== selectedGroup.id) {
if (isIndex || (selectedGroup && group.id !== selectedGroup.id)) {
href = this._getGroupTriggerHref(group);
label =
isIndex
Expand Down

0 comments on commit ce4155b

Please sign in to comment.