[TikiWiki-commits] [Git][tikiwiki/tiki][29.x] [BP][FIX] Articles: Prevent unintentionally reset all data on updating an article type
"Alain Cisirika \(@cisirikalain\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <68ccead5e1928_2cdecc46019c@gitlab-sidekiq-low-urgency-cpu-bound-v2-5c44cb6566-xt6s8.mail> |
Alain Cisirika pushed to branch 29.x at Tiki Wiki CMS Groupware / Tiki
Commits:
592e99f6 by Alain Cisirika at 2025-09-19T05:25:12+00:00
[BP][FIX] Articles: Prevent unintentionally reset all data on updating an article type
---
* [FIX] Articles: Prevent unintentionally reset all data on updating an article type
---
* [FIX] Prevent untentionionally resel all data on updating an article type
See merge request tikiwiki/tiki!8206
See merge request tikiwiki/tiki!8607
- - - - -
2 changed files:
- templates/tiki-article_types.tpl
- tiki-article_types.php
Changes:
=====================================
templates/tiki-article_types.tpl
=====================================
@@ -107,31 +107,53 @@
</table>
</div>
{if $prefs.article_custom_attributes eq 'y'}
- <div class="table-responsive article-types mb-4">
- <table class="table table-striped table-hover">
+ <div class="table-responsive article-types mb-4">
+ <table class="table table-striped table-hover align-middle">
+ <thead class="table-light">
<tr>
<th>{tr}Custom attribute{/tr}</th>
- <td></td> {* th changed to td to prevent ARIA empty header error *}
+ <th class="text-end">{tr}Action{/tr}</th>
</tr>
+ </thead>
+ <tbody>
{foreach from=$types[user].attributes item=att key=attname}
<tr>
<td>{$attname|escape}</td>
- <td class="action">
- <a class="tips" title=":{tr}Remove{/tr}" aria-label="{tr}Remove{/tr}" href="tiki-article_types.php?att_type={$types[user].type|escape:url}&att_remove={$att.relationId|escape:url}">
+ <td class="text-end">
+ <a id="remove_attr-{$attname}" class="btn btn-sm btn-outline-danger tips" title=":{tr}Remove{/tr}" aria-label="{tr}Remove custom attribute{/tr} {$attname|escape}" href="tiki-article_types.php?att_type={$types[user].type|escape:url}&att_remove={$att.relationId|escape:url}">
{icon name='remove' alt="{tr}Remove{/tr}"}
</a>
</td>
</tr>
+ {foreachelse}
+ <tr>
+ <td colspan="2" class="text-center text-muted fst-italic py-3">
+ {tr}No custom attributes defined for this type.{/tr}
+ </td>
+ </tr>
{/foreach}
+ </tbody>
+ <tfoot>
<tr>
- <td><input type="text" name="new_attribute[{$types[user].type|escape}]" aria-label="{tr}Custom attribute{/tr}" value="" class="form-control"></td>
- <td> </td>
+ <td colspan="2" class="p-2">
+ <label for="new_attribute_{$types[user].type|escape}" class="visually-hidden">{tr}Add new custom attribute{/tr}</label>
+ <input type="text" id="new_attribute_{$types[user].type|escape}" name="new_attribute[{$types[user].type|escape}]" class="form-control" placeholder="{tr}Add new custom attribute and click Save below{/tr}">
+ </td>
</tr>
- </table>
- </div>
+ </tfoot>
+ </table>
+ </div>
{/if}
<div class="text-center my-3">
<input type="submit" class="btn btn-primary" name="update_type" value="{tr}Save{/tr}">
</div>
{/section}
</form>
+{jq}
+ $(document).on("click", "[id^='remove_attr-']", function(e){
+ const confirmed = confirm("Are you sure you want to permanently remove this ?");
+ if (!confirmed) {
+ e.preventDefault();
+ }
+ });
+{/jq}
=====================================
tiki-article_types.php
=====================================
@@ -15,27 +15,27 @@ $inputConfiguration = [
'new_type' => 'string', //post
'remove_type' => 'word', //get
'update_type' => 'bool', //post
- 'use_ratings' => 'bool', //post
- 'show_pre_publ' => 'bool', //post
- 'heading_only' => 'bool', //post
- 'allow_comments' => 'bool', //post
- 'comment_can_rate_article' => 'bool', //post
- 'show_image' => 'bool', //post
- 'show_avatar' => 'bool', //post
- 'show_author' => 'bool', //post
- 'show_pubdate' => 'bool', //post
- 'show_reads' => 'bool', //post
- 'show_size' => 'bool', //post
- 'show_topline' => 'bool', //post
- 'show_subtitle' => 'bool', //post
- 'show_image_caption' => 'bool', //post
- 'show_linkto' => 'bool', //post
- 'creator_edit' => 'bool', //post
- 'new_attribute' => 'string', //post
'att_remove' => 'int', //post
],
- 'staticKeyFiltersForArrays' => [
+ 'staticKeyFiltersForArrays' => [
'type_array' => 'string', //post
+ 'use_ratings' => 'string', //post
+ 'show_pre_publ' => 'string', //post
+ 'heading_only' => 'string', //post
+ 'allow_comments' => 'string', //post
+ 'comment_can_rate_article' => 'string', //post
+ 'show_image' => 'string', //post
+ 'show_avatar' => 'string', //post
+ 'show_author' => 'string', //post
+ 'show_pubdate' => 'string', //post
+ 'show_reads' => 'string', //post
+ 'show_size' => 'string', //post
+ 'show_topline' => 'string', //post
+ 'show_subtitle' => 'string', //post
+ 'show_image_caption' => 'string', //post
+ 'show_linkto' => 'string', //post
+ 'creator_edit' => 'string', //post
+ 'new_attribute' => 'string', //post
],
]
];
@@ -111,6 +111,8 @@ if (isset($_REQUEST["add_type"])) {
$ok = $artlib->add_article_type_attribute($this_type, $_REQUEST["new_attribute"][$this_type]);
if (! $ok) {
Feedback::errorAndDie(tra("Failed to add attribute"), \Laminas\Http\Response::STATUS_CODE_409);
+ } else {
+ Feedback::success(tra("Article type attribute updated successfully"));
}
}
}
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/592e99f61527e8da443946737f2d09234b67fb9d
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/592e99f61527e8da443946737f2d09234b67fb9d
You're receiving this email because of your account on gitlab.com.
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs