Discourse toolkit to render forms

כן, זה אולי יעבוד. אנסה את זה.

אני מניח שידעתי מחפש אפשרות “טבעית של המסגרת” אבל זו בהחלט אופציה לגיטימית לחלוטין. תודה.

2 לייקים

{“type”:“object”,“properties”:{“translation”:{“type”:“string”}}}}

{“translation”: “[ציטוט="מערכת, עמוד:1, נושא:326439"]\n## תמונה\n\nמציג רכיב \u003cUppyImageUploader /\u003e.\n\n### טיפול בהעלאה\n\nברירת מחדל, הרכיב ייקבע אובייקט העלאה. נהוג שרק תרצה את ה-URL ואת ה-ID של ההעלאה. כדי להשיג זאת, ניתן להשתמש ב-@onSet על השדה:\n\n\n@action\nhandleUpload(upload, { set }) {\n set("upload_id", upload.id);\n set("upload_url", getURL(upload.url));\n}\n\n\n\n<Form as |form|>\n <form.Field\n @name="upload"\n @title="העלה"\n @onSet={{this.handleUpload}}\n as |field|\n >\n <field.Image />\n </form.Field>\n</Form>\n\n[/ציטוט]\n\nדוגמה זו מעניקה לי את השגיאה הבאה:\n\n\nvalidateConfig - uppy-upload.js:80:12\n\nשגיאה: הגדרת הקונפיגורציה החובה UppyUpload חסרה: סוג\n\n\n``\nUncaught (בבטחה) שגיאה: הגדרת הקונפיגורציה החובה UppyUpload חסרה: סוג\n validateConfig uppy-upload.js:80\n UppyUpload uppy-upload.js:113\n js uppy-image-uploader.gjs:32\n UppyImageUploader uppy-image-uploader.gjs:23\n createComponent base-component-manager.js:26\n Ember 2\n source chunk.e6b222d1aa255cdf70e5.d41d8cd9.js:98442\n Ember 12\n source chunk.e6b222d1aa255cdf70e5.d41d8cd9.js:100412\n source chunk.e6b222d1aa255cdf70e5.d41d8cd9.js:102123\n Ember 34\n show modal.js:73\n```\n\nאני חושד ש-<field.Image /> דורש פרופרטי @type :)”}

לייק 1

So things with image upload get yet more curious.

Sometimes when opening a file dialogue box to upload an image using a form control, I get this error:

selectedText - utilities.js:137:25
TypeError: ancestor is null
 const postMenuArea = ancestor.querySelector(".post-menu-area");
    <form.Field
      @name="upload_url_1"
      @title="Upload"
      @onSet={{this.handleUpload}}
      as |field|
    >
      <field.Image @type="branding"/>
    </form.Field>

This is especially curious because my Form is on a Modal which hasn’t anything to do with Posts.

Everything ends up working, it’s just slightly ugly on the browser console.

Cheers!

2 לייקים

{“translation”: "[ניתוח=“awesomerobot, post:4, topic:326439”]
אני חושב שהייבוא של הטופס היה לא נכון, אז עדכנתי את ההודעה המקורית
[/ניתוח]

אבל לא עדכנת את ההודעה המקורית או שהיא הוחזרה אחורה. ואני אבדתי עוד יותר זמן ממה שהייתי מוכן להודות על כך.

[ניתוח=“system, post:1, topic: 326439”]
הנה הדוגמה הבסיסית ביותר לטופס:

import Component מ"@glimmer/component";
import { action } מ"@ember/object";
import Form מ"discourse/form";

[/ניתוח]

ההוראות האלה מופיעות ב-GitHub? נכון? ואם כן, האם הם יכולים לקשר ל-GitHub?"}

3 לייקים

אה כן, לא היה לי הבנה שהנושא הזה נוצר מתוך מאגר התיעוד שלנו ולכן הוא נשוב והוחזר מעולם לא עקבתי אחרי זה… יש תיקון נכון בדרך עכשיו

3 לייקים

תודה!

ותיקון נוסף יהיה ליצור רכיב נושא (theme) בקוד המקור כדי שלא תתפתה לעשות את השינוי במקום הלא נכון שוב ואני אוכל להגיש בקשת משיכה (PR).

לייק 1

We do hide the edit button on Documentation > Developer Guides topics, but I think people get around it by using the keyboard shortcuts or quick edit. More things to hide/disable! :sweat_smile:

We have this at the bottom of every doc, with a link to the source file. So that’s probably the best thing to use if you want to make a PR:

לייק 1

Ah. Makes sense. Also, often rules don’t apply to admins.

Wait. What?

Oh. Oops. It is in tiny letters, but now that I see it, I to remember seeing it before. :person_shrugging:

I’ve made some more progress this time. I’m doing a bunch of fairly custom stuff (like I need to trigger some text that’s displayed when entering a field) that may keep me from being able to use it.

Any idea how I can trigger a function when entering a field? (Use case, when you enter the Digital Ocean API key field, I have text show up that describes how to get the API key).

EDIT: Why, yes. Dear https://ask.discourse.com/ was able to tell me! It’s painfully obvious once you know. :person_shrugging:

import { on } from "@ember/modifier";
...
  @action
  hostnameClicked(event) {
    this.setHelpText(i18n("pfaffmanager.help.hostname"));
  }
...
            <field.Input @type="text" {{on "click" this.hostnameClicked}} />
2 לייקים

this is incorrect - it should be validateUsername(name, value, { data, addError }) { or you will get a destructuring error.

5 לייקים