Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Set a Macro-Editor-Field "editable false" or "read only"

Rainer Emil November 9, 2022

Hi,

 

I have a macro with the String-Parameter "prefix".

"prefix" shall be set on creating the macro (empty string is allowed).
After that, it must not be editable.

<atlassian-plugin key="${atlassian.plugin.key}" name="${project.name}" plugins-version="2">
<!-- ... -->

<web-resource key="MyPlugin-resources" name="Web Resources">
<!-- ... -->
<resource type="download" name="my.js" location="/js/my.js"/>
<dependency>confluence.editor.actions:editor-macro-browser</dependency>
<context>macro-browser</context>
</web-resource>

<xhtml-macro name="mymacro" class="com.company.MyPlugin" key='mymacrokey'>
<parameters>
<parameter name="prefix" type="string" required="true" />
<parameter name="id" type="int" required="true" />
<parameter name="mydata" type="string" />
</parameters>
</xhtml-macro>
</atlassian-plugin>

 

My Idea is to use "setMacroJsOverride()" in the resource file "my.js" 

AJS.MacroBrowser.setMacroJsOverride("mymacro", {
   fields: {
      string: {
           "prefix": function (param) {
               var parameterField = AJS.MacroBrowser.ParameterFields["string"](param, {});

               var pref;
               try {pref = AJS.MacroBrowser.settings.selectedMacro.params["prefix"]}
               catch (e) {pref = null}

               if(pref != null){
                    console.log("set editable false");
               } else {
                    console.log("let editable true");
               }
               return parameterField;
            }
       }
});

I have two problems:

1.  I have no Idea how to do somthing like "parameterField.setEditable(false)".

2.  When Prefix is empty string, "prefix" is not saved, and the macro  is in the "else" block.
 There must be an other way to detect if the macro is just created or if it is edited. (Or perhaps if it ever has been saved)

 

Best Regards,

Rainer 

1 answer

1 accepted

0 votes
Answer accepted
Bill Bailey
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 9, 2022

Hello @Rainer Emil , probably a better place to pose your question is on https://community.developer.atlassian.com/ as this forum is mainly for end users and admins, and typically doesn't extend beyond developing user macros.

Rainer Emil November 9, 2022

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events