roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r821575 - in /roller/trunk/apps/weblogger: src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileView.java web/WEB-INF/classes/ApplicationResources.properties web/WEB-INF/jsps/editor/MediaFileView.jsp
Date Sun, 04 Oct 2009 18:59:09 GMT
Author: snoopdave
Date: Sun Oct  4 18:59:08 2009
New Revision: 821575

URL: http://svn.apache.org/viewvc?rev=821575&view=rev
Log:
Couple of small fixes:
- Only show move and delete buttons when files or directories are selected
- Fixed NPE when attempting to move files from search view

Modified:
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileView.java
    roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties
    roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileView.jsp

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileView.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileView.java?rev=821575&r1=821574&r2=821575&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileView.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileView.java
Sun Oct  4 18:59:08 2009
@@ -173,17 +173,16 @@
         MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
         try {
             MediaFileDirectory directory;
-            if (this.directoryId != null) {
+            if (StringUtils.isNotEmpty(this.directoryId)) {
                 directory = manager.getMediaFileDirectory(this.directoryId);
 
-            } else if (this.directoryPath != null) {
+            } else if (StringUtils.isNotEmpty(this.directoryPath)) {
                 directory = manager.getMediaFileDirectoryByPath(getActionWeblog(), this.directoryPath);
-                this.directoryId = directory.getId();
 
             } else {
                 directory = manager.getMediaFileRootDirectory(getActionWeblog());
-                this.directoryId = directory.getId();
             }
+            this.directoryId = directory.getId();
             this.directoryPath = directory.getPath();
 
             this.childDirectories = new ArrayList<MediaFileDirectory>();
@@ -194,18 +193,18 @@
 
             if ("type".equals(sortBy)) {
                 Collections.sort(this.childFiles,
-                        new MediaFileComparator(MediaFileComparatorType.TYPE));
+                    new MediaFileComparator(MediaFileComparatorType.TYPE));
 
             } else if ("date_uploaded".equals(sortBy)) {
                 Collections.sort(this.childFiles,
-                        new MediaFileComparator(MediaFileComparatorType.DATE_UPLOADED));
+                    new MediaFileComparator(MediaFileComparatorType.DATE_UPLOADED));
 
             } else { // default to sort by name
                 sortBy = "name";
                 Collections.sort(this.childDirectories,
-                        new MediaFileDirectoryComparator(DirectoryComparatorType.NAME));
+                    new MediaFileDirectoryComparator(DirectoryComparatorType.NAME));
                 Collections.sort(this.childFiles,
-                        new MediaFileComparator(MediaFileComparatorType.NAME));
+                    new MediaFileComparator(MediaFileComparatorType.NAME));
             }
 
             this.currentDirectory = directory;
@@ -269,7 +268,6 @@
         String fullPath = this.currentDirectory.getPath();
         if (fullPath.length() > 1) {
             String[] directoryNames = fullPath.substring(1).split("/");
-            String directoryPath = "";
             for (String directoryName : directoryNames) {
                 directoryPath = directoryPath + "/" + directoryName;
                 directoryHierarchy.add(new KeyValueObject(directoryPath, directoryName));

Modified: roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties?rev=821575&r1=821574&r2=821575&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties (original)
+++ roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties Sun Oct
 4 18:59:08 2009
@@ -981,7 +981,7 @@
 mediaFileAdd.description=Description
 mediaFileAdd.tags=Tags (space separated)
 mediaFileAdd.copyright=Copyright statement
-mediaFileAdd.directory=Place in directory
+mediaFileAdd.directory=Directory
 mediaFileAdd.includeGallery=Include in Gallery?
 mediaFileAdd.upload=Upload
 mediaFileAdd.multipleNames=(Multiple names)
@@ -1033,7 +1033,7 @@
 mediaFileEdit.description=Description
 mediaFileEdit.tags=Tags (space separated)
 mediaFileEdit.copyright=Copyright statement
-mediaFileEdit.directory=Place file under
+mediaFileEdit.directory=Directory
 mediaFileEdit.save=Save
 mediaFileEdit.cancel=Cancel
 mediaFileEdit.fileInfo=File info

Modified: roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileView.jsp
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileView.jsp?rev=821575&r1=821574&r2=821575&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileView.jsp (original)
+++ roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileView.jsp Sun Oct  4 18:59:08
2009
@@ -158,11 +158,13 @@
     <p class="subtitle">
         <s:text name="mediaFileView.path"/> /
         <s:iterator id="directory" value="currentDirectoryHierarchy">
+
             <s:url id="getDirectoryByPathUrl" action="mediaFileView">
                 <s:param name="directoryPath" value="#directory.key" />
                 <s:param name="weblog" value="%{actionWeblog.handle}" />
             </s:url>
             <s:a href="%{getDirectoryByPathUrl}"><s:property value="#directory.value"
/></s:a> /
+            
         </s:iterator>
     </p>
     <p class="pagetip">
@@ -179,37 +181,28 @@
     <s:hidden name="directoryId" />
     <input type="hidden" name="mediaFileId" value="" />
 
-    <%--
-    <s:url id="mediaFileHierarchicalViewURL" action="mediaFileHierarchicalView">
-        <s:param name="weblog" value="%{actionWeblog.handle}" />
-    </s:url>
-    <p><span style="font-weight:bold"><s:text name="mediaFileView.tabular"
/></span> |
-        <s:a href="%{mediaFileHierarchicalViewURL}"><s:text name="mediaFileView.hierarchy"
/></s:a></p>
-    --%>
-
     <div class="control">
 
         <span style="padding-left:20px">
             <s:text name="mediaFileView.sortby" />
-            <s:select name="sortBy" list="sortOptions" listKey="key"
+            <s:select id="sortByMenu" name="sortBy" list="sortOptions" listKey="key"
                   listValue="value"
                   onchange="document.mediaFileViewForm.submit();" />
         </span>
 
         <span style="float:right">
-            <input type="button" style="padding-right:20px"
+            <input id="deleteButton" type="button" style="padding-right:20px"
                value='<s:text name="mediaFileView.deleteSelected" />' onclick="onDeleteSelected()"
/>
 
-            <input type="button" style="padding-left:20px"
+            <input id="moveButton" type="button" style="padding-left:20px"
                value=<s:text name="mediaFileView.moveSelected" /> onclick="onMoveSelected()"
/>
 
-            <s:select name="selectedDirectory" list="allDirectories" listKey="id" listValue="path"
/>
+            <s:select id="moveTargetMenu" name="selectedDirectory" list="allDirectories"
listKey="id" listValue="path" />
         </span>
 
     </div>
 
 
-
     <%-- ***************************************************************** --%>
 
     <%-- Media file folder contents --%>
@@ -410,6 +403,35 @@
 
 <%-- ***************************************************************** --%>
 
+<%-- code to toggle buttons on/off as media file/directory selections change --%>
+
+<script type="text/javascript">
+    $(document).ready(function() {
+        $("#deleteButton").attr('disabled',true)
+        $("#moveButton").attr('disabled',true)
+        $("#moveTargetMenu").attr('disabled',true)
+
+        $("input[type=checkbox]").change(function() {
+            var count = 0;
+            $("input[type=checkbox]").each(function(index, element) {
+                if (element.checked) count++;
+            });
+            if (count == 0) {
+                $("#deleteButton").attr('disabled',true)
+                $("#moveButton").attr('disabled',true)
+                $("#moveTargetMenu").attr('disabled',true)
+            } else {
+                $("#deleteButton").attr('disabled',false)
+                $("#moveButton").attr('disabled',false)
+                $("#moveTargetMenu").attr('disabled',false)
+            }
+        });
+    });
+</script>
+
+
+<%-- ***************************************************************** --%>
+
 <%-- code to launch Media File Edit lightbox when user clicks a media file --%>
 
 <script type="text/javascript">
@@ -429,7 +451,7 @@
     }
 
     YAHOO.namespace("mediaFileEditor");
-    function init() {
+    $(document).ready(function() {
         YAHOO.mediaFileEditor.lightbox = new YAHOO.widget.Panel(
             "mediafile_edit_lightbox", {
                 modal:    true,
@@ -441,8 +463,7 @@
             }
         );
         YAHOO.mediaFileEditor.lightbox.render(document.body);
-    }
-    YAHOO.util.Event.addListener(window, "load", init);
+    });
 
 </script>
 



Mime
View raw message