Explorer

html-ui.part-tools

description
(en) The tools under the content of a part page that can be edited: the parts that reference it (the text of definy_find_references), renaming (definy_rename_part) and deleting
type
Fn(language: String, project: String, branch: String, part: String, references: String) -> List<@html.node>
expression
fn(language$990, project$0, branch$1, part$2, references$3) =>
  let lines$5 = @core.string-split(text: $3, separator: "\n");
  let count$4 = @core.minus(left: @core.list-length(value: $5), right: 1);
  @html.concat(
    lists: [
      [
        @html-ui.text-element(
          name: "h2",
          text: @core.string-join(
            items: [
              @html-ui.text(
                language: $990,
                en: "Parts that reference it (",
                ja: "参照しているパーツ (",
                eo: "Partoj, kiuj referencas ĝin ("
              ),
              @std.number-to-string(value: $4),
              ")"
            ],
            separator: ""
          )
        ),
        @html.element(
          name: "ul",
          attributes: [],
          children: @html.concat(
            lists: @core.list-map(
              T: String,
              U: List<@html.node>,
              f: fn(item$6) =>
                match @std.string-starts-with(value: $6, prefix: "  ") {
                  true =>
                    let name$7 = @core.string-slice(value: $6, start: 2, end: @core.string-length(value: $6));
                    [
                      @html.element(
                        name: "li",
                        attributes: [],
                        children: [
                          @html.element(
                            name: "a",
                            attributes: [{name: "href", value: @core.string-join(items: ["/p/", $0, "/", $1, "/", $7], separator: "")}],
                            children: [@html.text(text: $7)]
                          )
                        ]
                      )
                    ],
                  false =>
                    []
                },
              xs: $5
            )
          )
        ),
        @html-ui.text-element(
          name: "h2",
          text: @html-ui.text(language: $990, en: "Rename", ja: "名前を変える", eo: "Renomi")
        ),
        @html.element(
          name: "p",
          attributes: [],
          children: @html-ui.text-nodes(
            language: $990,
            en: [
              @html.text(
                text: "Also rewrites the parts of this branch that reference this part, in one snapshot. To move it to another module, change the "
              ),
              @html-ui.text-element(name: "code", text: "module.name"),
              @html.text(text: ".")
            ],
            ja: [
              @html.text(
                text: "このブランチでこのパーツを参照しているパーツも書き換えて, 1 つのスナップショットにします。別のモジュールへ移すときは "
              ),
              @html-ui.text-element(name: "code", text: "モジュール.名前"),
              @html.text(text: " を変えます。")
            ],
            eo: [
              @html.text(
                text: "Ankaŭ reskribas la partojn de ĉi tiu branĉo, kiuj referencas ĉi tiun parton, en unu momentfoto. Por movi ĝin al alia modulo, ŝanĝu la "
              ),
              @html-ui.text-element(name: "code", text: "modulo.nomo"),
              @html.text(text: ".")
            ]
          )
        )
      ],
      @html-ui.tool-form(
        tool: "definy_rename_part",
        then: "/p/{project}/{branch}/{to}",
        confirm: "",
        fields: [
          @html-ui.hidden(name: "project", value: $0),
          @html-ui.hidden(name: "branch", value: $1),
          @html-ui.hidden(name: "part", value: $2),
          @html.element(
            name: "input",
            attributes: [{name: "name", value: "to"}, {name: "required", value: ""}, {name: "value", value: $2}],
            children: []
          )
        ],
        button: @html-ui.text(language: $990, en: "Rename", ja: "名前を変える", eo: "Renomi")
      ),
      [
        @html-ui.text-element(name: "h2", text: @html-ui.text(language: $990, en: "Delete", ja: "消す", eo: "Forigi"))
      ],
      @html-ui.tool-form(
        tool: "definy_create_snapshot",
        then: @core.string-join(
          items: [
            "/p/",
            $0,
            "/",
            $1,
            "/",
            @html-ui.segment(segments: @core.string-split(text: $2, separator: "."), index: 0)
          ],
          separator: ""
        ),
        confirm: @core.string-join(
          items: [
            @html-ui.text(language: $990, en: "Delete the part ", ja: "パーツ ", eo: "Ĉu forigi la parton "),
            $2,
            @html-ui.text(language: $990, en: "?", ja: " を消しますか?", eo: "?"),
            match @core.equal(left: $4, right: 0) {
              true =>
                "",
              false =>
                @core.string-join(
                  items: [
                    @html-ui.text(language: $990, en: " The ", ja: " 参照している ", eo: " La "),
                    @std.number-to-string(value: $4),
                    @html-ui.text(
                      language: $990,
                      en: " parts that reference it will have type errors, and no snapshot can be taken.",
                      ja: " 個のパーツが型エラーになり, スナップショットを作れません。",
                      eo: " partoj, kiuj referencas ĝin, havos tiperarojn, kaj ne eblos fari momentfoton."
                    )
                  ],
                  separator: ""
                )
            }
          ],
          separator: ""
        ),
        fields: [
          @html-ui.hidden(name: "project", value: $0),
          @html-ui.hidden(name: "branch", value: $1),
          @html-ui.hidden(name: "message", value: @core.string-concat(left: "Delete ", right: $2)),
          @html-ui.hidden-json(
            name: "changes",
            value: @core.string-join(
              items: ["[{\"part\":", @definy.json-string-literal(value: $2), ",\"delete\":true}]"],
              separator: ""
            )
          )
        ],
        button: @html-ui.text(
          language: $990,
          en: "Delete this part",
          ja: "このパーツを消す",
          eo: "Forigi ĉi tiun parton"
        )
      )
    ]
  )
visibility
public
html-ui.part-tools (project html-ui, branch main, snapshot Daaw3vbJhY15cDW6JsA4JuXvffjj_qFyxoZQMUM8hvQ)
id: S7077BtmDjgN9W3_7YlDmpLZF9LxSfe3lqqpQfmcKHU
content hash: wKMQUmko8ooIRaWhRNDsPqKPmmKyfESY3FJVJUjANP0