tgrosinger / tw5-checklist

Simple checklist widget for TiddlyWiki5:
https://tgrosinger.github.io/tw5-checklist/
51 stars 13 forks source link

New option to hide the input form group above the checklist - solution provided #50

Open bepuzzled opened 3 years ago

bepuzzled commented 3 years ago

ok, I found a solution; feel free to use or implement the solution differently (or not all)

The following tweaks provides an additional option that hides the input form to add new items to the list above the list:

  1. insert a new configuration field in $:/plugins/tgrosinger/tw5-checklist/Configuration:
  <tr>
    <th align="left">Show input box for new entries above the list:</th>
    <td>
        <$checkbox field="showinput" tiddler="$:/plugins/tgrosinger/tw5-checklist/Configuration"
            checked="true" unchecked="false" default="true"></$checkbox>
    </td>
  </tr>
  1. in $:/plugins/tgrosinger/tw5-checklist/stylesheet, insert a class .hideme under /* input form */:
.hideme {
    display:none;
}
  1. in $:/plugins/tgrosinger/tw5-checklist/checkbox-wikirule.js insert:
/*
Retrieve the configuration state indicating whether the input block should be shown above the list
*/

exports.showInput= function() {
    var configWidgetTitle = "$:/plugins/tgrosinger/tw5-checklist/Configuration";
    var configWidgetFields = $tw.wiki.getTiddler(configWidgetTitle).fields;

    var showInputBlock = configWidgetFields["show-input"] || "true";
    return (showInputBlock === "true");
}

and insert this

        attributes: {
                class: {type: "string", value: (this.showInput()?"":"hideme")}
        },

just below:

    // Start the list with a "New List Item" placeholder
    listItems.push({
        type: "element",
        tag: "li",
tw-FRed commented 2 years ago

Hi,

In step 1., the checkbox widget definition:

<$checkbox field="showinput" ...

should read:

<$checkbox field="show-input" ...

and the last line of Step 3. showInput function should be:

};

HTH,

Fred

Hydrowood0 commented 4 months ago

Hi, @tw-FRed , @bepuzzled , @tgrosinger , Good Job! However, u need to use $tw.utils.repackPlugin to make the new Configuration displayed in the plugins setting page instead of clicking the link and jumping to your own modified one. Here is the code. $tw.utils.repackPlugin("$:/plugins/tgrosinger/tw5-checklist",["/data/tiddlywiki/MyPluginStore/tgrosinger/tw5-checklist/README.md", "$:/plugins/tgrosinger/tw5-checklist/checkbox-wikirule.js", "$:/plugins/tgrosinger/tw5-checklist/checklist.js", "$:/plugins/tgrosinger/tw5-checklist/Configuration", "$:/plugins/tgrosinger/tw5-checklist/license", "$:/plugins/tgrosinger/tw5-checklist/readme", "$:/plugins/tgrosinger/tw5-checklist/stylesheet", "$:/plugins/tgrosinger/tw5-checklist/Usage" ],null)

Here is the plugin which is packed and having

an additional option that hides the input form to add new items to the list above the list:

0.16: an additional option that hides the input form to add new items to the list above the list:

0.17: Modify the CSS so that clear-all and input & add are all displayed on the first line.

$__plugins_tgrosinger_tw5-checklist.json drag this JSON into your Tiddlywiki!

0.17.1 Replace remove button The remove button just comments out the lines instead of deleting them.

$__plugins_tgrosinger_tw5-checklist.jsondrag this JSON into your Tiddlywiki!

I cannot push my branch due to remote: Your account is suspended. Please visit https://support.github.com for more information. fatal: unable to access 'https://github.com/Hydrowood0/tw5-checklist.git/': The requested URL returned error: 403