浏览代码

Refactor bookmark modal

- Use `getDisplayName` to have proper fallback for the MUC name
- Don't use the term "Unbookmark". There might be other reasons for
opening the bookmark modal besides removing a bookmark.
JC Brand 2 年之前
父节点
当前提交
465aa38222
共有 45 个文件被更改,包括 14588 次插入14809 次删除
  1. 0 1
      dev.html
  2. 394 399
      src/i18n/af/LC_MESSAGES/converse.po
  3. 423 428
      src/i18n/ar/LC_MESSAGES/converse.po
  4. 424 430
      src/i18n/bg/LC_MESSAGES/converse.po
  5. 359 364
      src/i18n/ca/LC_MESSAGES/converse.po
  6. 423 428
      src/i18n/converse.pot
  7. 359 365
      src/i18n/cs/LC_MESSAGES/converse.po
  8. 423 428
      src/i18n/da/LC_MESSAGES/converse.po
  9. 260 265
      src/i18n/de/LC_MESSAGES/converse.po
  10. 423 428
      src/i18n/el/LC_MESSAGES/converse.po
  11. 423 429
      src/i18n/eo/LC_MESSAGES/converse.po
  12. 260 265
      src/i18n/es/LC_MESSAGES/converse.po
  13. 260 265
      src/i18n/eu/LC_MESSAGES/converse.po
  14. 423 428
      src/i18n/fa/LC_MESSAGES/converse.po
  15. 359 365
      src/i18n/fi/LC_MESSAGES/converse.po
  16. 359 364
      src/i18n/fr/LC_MESSAGES/converse.po
  17. 359 364
      src/i18n/gl/LC_MESSAGES/converse.po
  18. 260 266
      src/i18n/he/LC_MESSAGES/converse.po
  19. 423 429
      src/i18n/hi/LC_MESSAGES/converse.po
  20. 359 364
      src/i18n/hu/LC_MESSAGES/converse.po
  21. 394 399
      src/i18n/id/LC_MESSAGES/converse.po
  22. 260 265
      src/i18n/it/LC_MESSAGES/converse.po
  23. 260 265
      src/i18n/ja/LC_MESSAGES/converse.po
  24. 260 265
      src/i18n/lt/LC_MESSAGES/converse.po
  25. 423 428
      src/i18n/mr/LC_MESSAGES/converse.po
  26. 359 364
      src/i18n/nb/LC_MESSAGES/converse.po
  27. 359 365
      src/i18n/nl/LC_MESSAGES/converse.po
  28. 260 265
      src/i18n/nl_BE/LC_MESSAGES/converse.po
  29. 359 365
      src/i18n/oc/LC_MESSAGES/converse.po
  30. 359 364
      src/i18n/pl/LC_MESSAGES/converse.po
  31. 260 265
      src/i18n/pt/LC_MESSAGES/converse.po
  32. 260 265
      src/i18n/pt_BR/LC_MESSAGES/converse.po
  33. 394 400
      src/i18n/ro/LC_MESSAGES/converse.po
  34. 359 364
      src/i18n/ru/LC_MESSAGES/converse.po
  35. 260 265
      src/i18n/sv/LC_MESSAGES/converse.po
  36. 423 428
      src/i18n/th/LC_MESSAGES/converse.po
  37. 359 364
      src/i18n/tr/LC_MESSAGES/converse.po
  38. 359 364
      src/i18n/ug/LC_MESSAGES/converse.po
  39. 424 430
      src/i18n/uk/LC_MESSAGES/converse.po
  40. 423 428
      src/i18n/vi/LC_MESSAGES/converse.po
  41. 394 399
      src/i18n/zh_CN/LC_MESSAGES/converse.po
  42. 394 399
      src/i18n/zh_TW/LC_MESSAGES/converse.po
  43. 1 7
      src/plugins/bookmark-views/components/bookmark-form.js
  44. 8 6
      src/plugins/bookmark-views/components/templates/form.js
  45. 4 5
      src/plugins/bookmark-views/utils.js

+ 0 - 1
dev.html

@@ -28,7 +28,6 @@
     });
     });
 
 
     converse.initialize({
     converse.initialize({
-        i18n: 'ug',
         theme: 'dracula',
         theme: 'dracula',
         auto_away: 300,
         auto_away: 300,
         enable_smacks: true,
         enable_smacks: true,

文件差异内容过多而无法显示
+ 394 - 399
src/i18n/af/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 423 - 428
src/i18n/ar/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 424 - 430
src/i18n/bg/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 359 - 364
src/i18n/ca/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 423 - 428
src/i18n/converse.pot


文件差异内容过多而无法显示
+ 359 - 365
src/i18n/cs/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 423 - 428
src/i18n/da/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 260 - 265
src/i18n/de/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 423 - 428
src/i18n/el/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 423 - 429
src/i18n/eo/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 260 - 265
src/i18n/es/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 260 - 265
src/i18n/eu/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 423 - 428
src/i18n/fa/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 359 - 365
src/i18n/fi/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 359 - 364
src/i18n/fr/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 359 - 364
src/i18n/gl/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 260 - 266
src/i18n/he/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 423 - 429
src/i18n/hi/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 359 - 364
src/i18n/hu/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 394 - 399
src/i18n/id/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 260 - 265
src/i18n/it/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 260 - 265
src/i18n/ja/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 260 - 265
src/i18n/lt/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 423 - 428
src/i18n/mr/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 359 - 364
src/i18n/nb/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 359 - 365
src/i18n/nl/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 260 - 265
src/i18n/nl_BE/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 359 - 365
src/i18n/oc/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 359 - 364
src/i18n/pl/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 260 - 265
src/i18n/pt/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 260 - 265
src/i18n/pt_BR/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 394 - 400
src/i18n/ro/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 359 - 364
src/i18n/ru/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 260 - 265
src/i18n/sv/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 423 - 428
src/i18n/th/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 359 - 364
src/i18n/tr/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 359 - 364
src/i18n/ug/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 424 - 430
src/i18n/uk/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 423 - 428
src/i18n/vi/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 394 - 399
src/i18n/zh_CN/LC_MESSAGES/converse.po


文件差异内容过多而无法显示
+ 394 - 399
src/i18n/zh_TW/LC_MESSAGES/converse.po


+ 1 - 7
src/plugins/bookmark-views/components/bookmark-form.js

@@ -18,13 +18,7 @@ class MUCBookmarkForm extends CustomElement {
     }
     }
 
 
     render () {
     render () {
-        return tpl_muc_bookmark_form(
-            Object.assign(this.model.toJSON(), {
-                'bookmark': this.bookmark,
-                'onCancel': ev => this.removeBookmark(ev),
-                'onSubmit': ev => this.onBookmarkFormSubmitted(ev)
-            })
-        );
+        return tpl_muc_bookmark_form(this)
     }
     }
 
 
     onBookmarkFormSubmitted (ev) {
     onBookmarkFormSubmitted (ev) {

+ 8 - 6
src/plugins/bookmark-views/components/templates/form.js

@@ -2,17 +2,19 @@ import { html } from "lit";
 import { __ } from 'i18n';
 import { __ } from 'i18n';
 
 
 
 
-export default (o) => {
-    const name = o.bookmark?.get('name') ?? o.name;
-    const nick = o.bookmark?.get('nick') ?? o.nick;
+export default (el) => {
+    const name = el.model.getDisplayName();
+    const nick = el.bookmark?.get('nick') ?? el.model.get('nick');
+
     const i18n_heading = __('Bookmark for "%1$s"', name);
     const i18n_heading = __('Bookmark for "%1$s"', name);
     const i18n_autojoin = __('Would you like this groupchat to be automatically joined upon startup?');
     const i18n_autojoin = __('Would you like this groupchat to be automatically joined upon startup?');
     const i18n_remove = __('Remove');
     const i18n_remove = __('Remove');
     const i18n_name = __('The name for this bookmark:');
     const i18n_name = __('The name for this bookmark:');
     const i18n_nick = __('What should your nickname for this groupchat be?');
     const i18n_nick = __('What should your nickname for this groupchat be?');
-    const i18n_submit = o.bookmark ? __('Update') : __('Save');
+    const i18n_submit = el.bookmark ? __('Update') : __('Save');
+
     return html`
     return html`
-        <form class="converse-form chatroom-form" @submit=${o.onSubmit}>
+        <form class="converse-form chatroom-form" @submit=${(ev) => el.onBookmarkFormSubmitted(ev)}>
             <legend>${i18n_heading}</legend>
             <legend>${i18n_heading}</legend>
             <fieldset class="form-group">
             <fieldset class="form-group">
                 <label for="converse_muc_bookmark_name">${i18n_name}</label>
                 <label for="converse_muc_bookmark_name">${i18n_name}</label>
@@ -28,7 +30,7 @@ export default (o) => {
             </fieldset>
             </fieldset>
             <fieldset class="form-group">
             <fieldset class="form-group">
                 <input class="btn btn-primary" type="submit" value="${i18n_submit}">
                 <input class="btn btn-primary" type="submit" value="${i18n_submit}">
-                ${o.bookmark ? html`<input class="btn btn-secondary button-remove" type="button" value="${i18n_remove}" @click=${o.onCancel}>` : '' }
+                    ${el.bookmark ? html`<input class="btn btn-secondary button-remove" type="button" value="${i18n_remove}" @click=${(ev) => el.removeBookmark(ev)}>` : '' }
             </fieldset>
             </fieldset>
         </form>
         </form>
     `;
     `;

+ 4 - 5
src/plugins/bookmark-views/utils.js

@@ -7,18 +7,17 @@ import { checkBookmarksSupport } from '@converse/headless/plugins/bookmarks/util
 
 
 export function getHeadingButtons (view, buttons) {
 export function getHeadingButtons (view, buttons) {
     if (api.settings.get('allow_bookmarks') && view.model.get('type') === _converse.CHATROOMS_TYPE) {
     if (api.settings.get('allow_bookmarks') && view.model.get('type') === _converse.CHATROOMS_TYPE) {
-        const bookmarked = view.model.get('bookmarked');
         const data = {
         const data = {
-            'i18n_title': bookmarked ? __('Unbookmark this groupchat') : __('Bookmark this groupchat'),
-            'i18n_text': bookmarked ? __('Unbookmark') : __('Bookmark'),
-            'handler': ev => view.showBookmarkModal(ev),
+            'i18n_title': __('Bookmark this groupchat'),
+            'i18n_text': __('Bookmark'),
+            'handler': (ev) => view.showBookmarkModal(ev),
             'a_class': 'toggle-bookmark',
             'a_class': 'toggle-bookmark',
             'icon_class': 'fa-bookmark',
             'icon_class': 'fa-bookmark',
             'name': 'bookmark'
             'name': 'bookmark'
         };
         };
         const names = buttons.map(t => t.name);
         const names = buttons.map(t => t.name);
         const idx = names.indexOf('details');
         const idx = names.indexOf('details');
-        const data_promise = checkBookmarksSupport().then(s => (s ? data : null));
+        const data_promise = checkBookmarksSupport().then((s) => (s ? data : null));
         return idx > -1 ? [...buttons.slice(0, idx), data_promise, ...buttons.slice(idx)] : [data_promise, ...buttons];
         return idx > -1 ? [...buttons.slice(0, idx), data_promise, ...buttons.slice(idx)] : [data_promise, ...buttons];
     }
     }
     return buttons;
     return buttons;

部分文件因为文件数量过多而无法显示