Closed amenk closed 7 years ago
For wiki pages something similar, but different happens. It is attached as _test.png_
The behaviour of saving the diagram as test_1.png
is normal: Readmine (at least until 3.2.0) does not have the API to delete attachments, and for new releases I need to try and implement the code.
So I needed a way to "version" the diagram and so the diagram is saved with a numeric suffix that will be incremented every time the diagram is saved. At the same time the body is updated changing the reference from test.png
to test_1.png
.
I've just tested the drawio_attach
macro with Redmine 3.3.1, png diagram format, and with issue and wiki pages and it works fine.
For the issue, it seems that the issue body is not update; maybe there is a difference for the APIs between Redmine and EasyRedmine. Try another time but with the browser console open and check if there are javascript errors.
For the Wiki... at this time I have no idea. I will try to reproduce the proble.
But there is a versioning - if you upload a file with the same name, it is replaced with a new version (or is this only in ER) ? The body updating does not seem to work though ...
Is it possible to put an option to always save under the same name ? (if only for ER - but I believe stock redmine has this as well)
With attachments (at least in standard Redmine) will not replace an attachment you upload two files with the same name. You can try with two different images using the same name, both will appear in the attachment list. For the body updating... what is your version of EasyRedmine? Maybe I can match a similar version of Redmine and reproduce the issue.
Interesting. In ER it is definitely the case that images get replaced by a new version. But I do not know if the API is the same. Maybe you can try in the ER branch to disable the file-renaming or give me a hint where it is done. This would magically solve the need for the body updating :-)
But now it seems to save also with foo.png for {{drawio_attach("foo.png")}}
in issues - no clue why.
The are coming because I use "
... I found the versioning code and will see what happens if I disable i
works
--- a/lib/redmine_drawio/macros.rb
+++ b/lib/redmine_drawio/macros.rb
@@ -136,11 +136,12 @@ EOF
if canEdit
# Diagram and document are editable
- if diagramName =~ /_\d+\./
- saveName = diagramName.sub(/_(\d+)/) {|v| v.next } # increment version
- else
- saveName = diagramName.sub(/(\.\w+)$/, '_1\1') # set version to _1
- end
+# if diagramName =~ /_\d+\./
+# saveName = diagramName.sub(/_(\d+)/) {|v| v.next } # increment version
+# else
+# saveName = diagramName.sub(/(\.\w+)$/, '_1\1') # set version to _1
+# end
+ saveName = diagramName
else
# Diagram cannot be saved, it wil become not editable
saveName = nil
Can we put a detection for easyredmine (if a easy Plugin is present?) and include that code? Where to disable the modification of the body? Even it is not working, it should be disabled I think..
This is what happens when I modify a diagram without the "versioning" suffix: The green image is the first editing attempt, the red (it looks pinker than red) is the second. As you can see the image is not replaced, and as the attachment is requested by name, it is not guaranteed to pick the latest image. Can you confirm that with EasyRedmine this doesn't happen, that when saving the image in the attachment list is replaced and not appended to list? If so than it is needed some code to disable the "versioning" (I would prefer to remove it completely, i would simplify the javascript too). A sort of detection is also needed for the EasyRedmine toolbar covering the iframe of the editor, so the detection is already necessary. But I'm not sure on the detection by testing the presence of a EasyRedmine plugin, there are plugins that can be used for free (with limitations) on the standard Redmine. I need to investigate.
Yes I can confirm it is not like on your screenshot but with proper replacing and automatic versioning by easyredmine with my small change above.
Hi amenk, can you try again from the easredmineCompat branch? I've introduced an EasyRedmine detection, so I hope the code will work fine with both ER and Redmine. The code need to be cleaned but if this works I can go on with the changes.
Works well.
Good, now I can clean the code and handle the toolbar covering the iframe.
Plugin is almost complete, I would try to implement request #21 before release a new version.
If you want you can try the current version for EasyRedmine from the develop
branch.
fixed in develop
Easyredmine / EasyredmineCompat Branch
Steps to reproduce
See:
Want to see: