rejetto forum

Move file Drop down menu

0 Members and 1 Guest are viewing this topic.

Offline johnjaykay

  • Occasional poster
  • *
    • Posts: 21
    • View Profile
Hello all! Thanks for the excellent software. I am trying to incorporate a move feature by moving files to a specific folder by selecting a dropdown menu...

My goal is to have user select a drop down box that has pre selected destinations of moving the file or folder selected. Once the user selects the file or folder to move, they can move by selecting from list of choices. The two destinations I want to user are:

"/../Music/"
"/../Photos/"

This would move the selected file/folder to another folder in that directory. Does this make sense to anyone? Rather than having them type full directory each time, they would be able to select pre-determined location. Thanks! :)


Offline johnjaykay

  • Occasional poster
  • *
    • Posts: 21
    • View Profile
Also, at the same time would it be possible to add a comment for that file after or before it is moved, such as once I select destination, another text box is available to add comment to that file. I am not sure how to even begin with this.

Thanks again.


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
you should be good with html, and i fear also with javascript (or hire someone who is it).

that's how i would go for it, to avoid losing next template updates:
i would go in root properties, diff template, and would type something like this (not tested!)

[+more onload]
$('button:contains(Move)').click(function(){
  alert('Do what you want to do here');
});
« Last Edit: January 25, 2011, 05:06:06 PM by rejetto »


Offline johnjaykay

  • Occasional poster
  • *
    • Posts: 21
    • View Profile
How about some help with this... I want the destination folder to be "%folder%../music/" every time I select the move button. Just want a button that moves to that destination and asks "Are you sure?"....

Do I modify the moveclicked() function???

function moveClicked() {
    ezprompt("{.!Enter the destination folder.}", {type:"text"}, function(s){
        $.post("?mode=section&id=ajax.move", {"dst":s, files:selectedFilesAsStr()}, function(res){
            var a = res.split(";");

***possibly edit var a = "path"*** I can't get this to work


            if (a.length < 2)
                return alert($.trim(res));
            var failed = 0;
            var ok = 0;
            var msg = "";
            for (var i=0; i<a.length-1; i++) {
                var s = $.trim(a);
                if (!s.length) {
                    ok++;
                    continue;
                }
                failed++;
                msg += s+"\n";
            }
            if (failed)
                msg = "{.!We met the following problems:.}\n"+msg;
            msg = (ok ? ok+" {.!files were moved..}\n" : "{.!No file was moved..}\n")+msg;
            alert(msg);
            if (ok) location = location; // reload
        });
    });
}//moveClicked


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
you should first decide if you want to add a button or change the behavior of the existing move button.

anyway that's not the right point for changing, it's the "dst":s


Offline johnjaykay

  • Occasional poster
  • *
    • Posts: 21
    • View Profile
I wanted to modify the move button. That was it. If i use %folder%, it converts in the text box to "/". Why doesn't it convert to the current folder that I am in?

Thanks.


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
i found why %folder% is converted to /, but you can skip the explanation and go for the solution;
the text/function you are editing is actually downloaded by the browser in a static way, and thus downloaded only once.
This is by-design for the default template, it's not a general rule of HFS and other templates can opt to do differently.
All the things that are not so static should be put elsewhere (in the main section, where you read this object will store some %symbols% in the javascript space, so that libs can read them).
But i will not go this way, because we don't actually need %folder% to make it work.


solution:
use this function.
it will work if you the "music" folder is accessible via HFS.
Code: [Select]
function moveClicked() {
    var s = selectedFilesAsStr();
    if (!s) return alert('Select something first');
    if (!confirm('Are you sure?')) return;
    $.post('?mode=section&id=ajax.move', {'dst':'../music/', files:s}, function(res){
        var a = res.split(";");
        if (a.length < 2)
            return alert($.trim(res));
        var failed = 0;
        var ok = 0;
        var msg = "";
        for (var i=0; i<a.length-1; i++) {
            var s = $.trim(a[i]);
            if (!s.length) {
                ok++;
                continue;
            }
            failed++;
            msg += s+"\n";
        }
        if (failed)
            msg = "{.!We met the following problems:.}\n"+msg;
        msg = (ok ? ok+" {.!files were moved..}\n" : "{.!No file was moved..}\n")+msg;
        alert(msg);
        if (ok) location = location; // reload
    });
}//moveClicked


Offline johnjaykay

  • Occasional poster
  • *
    • Posts: 21
    • View Profile
THX FOR THE REPLY REJETTO. HERE IS WHAT I'M DOING

FOLODER STRUCTURE

>FILES
  >>MEDIA
    >>>UPLOAD
    >>>MUSIC

THE MOVE BUTTON MOVES FROM UPLOAD FOLDER TO THE MUSIC FOLDER EVERY TIME.

SOMETIMES I MOVE FILES AND SOMETIME FOLDERS. WILL THIS WORK FOR THAT? I KEEP GETTING "FORBIDDEN" MESSAGE.


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
that's because the [ajax.move] script is check you for permissions on the folder.
it was not designed for your needs.
you should change that part as well.
but be careful with security.


Offline johnjaykay

  • Occasional poster
  • *
    • Posts: 21
    • View Profile
Here's how I ended up doing it. Not very pretty but it works.


Code: [Select]
function moveClicked() {
;

var a = getSelection();
            if (a.size() < 1)
return alert("You must select atleast 1 file/folder.");

d$= '%'+'folder%../music';

   ezprompt("{.!Are you sure you want to move files?.}", {'type':'hidden', 'default': d$,}, function(s){
        $.post("?mode=section&id=ajax.move", {"dst":s, files:selectedFilesAsStr()}, function(res){
            var a = res.split(";");

            if (a.length < 2)
                return alert($.trim(res));

            var failed = 0;
            var ok = 0;
            var msg = "";
            for (var i=0; i<a.length-1; i++) {
                var s = $.trim(a[i]);
                if (!s.length) {
                    ok++;
                    continue;
                }
                failed++;
                msg += s+"\n";
            }
            if (failed)
                msg = "{.!ERROR.}\n"+msg;
            msg = (ok ? ok+" {.!Files moved..}\n" : "{.!Files not moved..}\n")+msg;
            alert(msg);


           
 if (ok) location = location; // reload
        });
    });

}//moveClicked


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile