Changeset 2360 in products


Ignore:
Timestamp:
May 19, 2010 6:23:11 PM (9 years ago)
Author:
mylan
Message:

Toggle trunk for plone4 release.
Plone-3 release moved to brances/plone3.

Merged revisions 3345-3351,3355-3359,3361-3370,3372-3390,3397 via svnmerge from
http://svn.quintagroup.com/products/quintagroup.referencedatagridfield/branches/plone4

Fixed minor conflicts in:

  • ./setup.py
  • ./quintagroup/referencedatagridfield/configure.zcml

........

r3345 | mylan | 2010-05-13 15:51:53 +0300 (Thu, 13 May 2010) | 1 line


Update requirements: in setup.py, included its in configure.zcml

........

r3346 | mylan | 2010-05-13 17:42:07 +0300 (Thu, 13 May 2010) | 1 line


Added refdatagridbrowser_popup view with popup customization for the referencedatagridfield

........

r3347 | mylan | 2010-05-13 17:50:14 +0300 (Thu, 13 May 2010) | 1 line


Added and registered datagridref_popup named template for the ReferenceDataGridWidget?

........

r3348 | mylan | 2010-05-13 18:59:34 +0300 (Thu, 13 May 2010) | 1 line


Fix typo in named_template_adapter

........

r3349 | mylan | 2010-05-13 19:00:21 +0300 (Thu, 13 May 2010) | 1 line


Prevent breakage of datagridwidget_manipulators.pt

........

r3350 | mylan | 2010-05-13 20:01:59 +0300 (Thu, 13 May 2010) | 1 line


Initial reference popup integration

........

r3351 | mylan | 2010-05-13 22:05:47 +0300 (Thu, 13 May 2010) | 1 line


Update default referencebrowser javascript / datagrid field to popup work correctly for new added row

........

r3355 | mylan | 2010-05-14 17:21:23 +0300 (Fri, 14 May 2010) | 1 line


Fix reference browser url calculation on the view - pass additional paramters

........

r3356 | mylan | 2010-05-14 17:26:49 +0300 (Fri, 14 May 2010) | 1 line


Update datagridwidget_manipulators template for additional params pass to datagridref_popup view

........

r3357 | mylan | 2010-05-14 17:27:59 +0300 (Fri, 14 May 2010) | 1 line


Remove order_idx from the additional parmeters - it will be calulated with jQuery

........

r3358 | mylan | 2010-05-14 17:29:20 +0300 (Fri, 14 May 2010) | 1 line


Updated jQuery processor on UID adding

........

r3359 | mylan | 2010-05-14 17:31:54 +0300 (Fri, 14 May 2010) | 1 line


Added focus and blur event-handlers to referencedatagridwidget javascripts

........

r3361 | mylan | 2010-05-17 18:08:44 +0300 (Mon, 17 May 2010) | 1 line


Fixed all overlays bindings to same target issue

........

r3362 | mylan | 2010-05-17 18:29:07 +0300 (Mon, 17 May 2010) | 1 line


Fix error with everlay windows autoclosing

........

r3363 | mylan | 2010-05-17 18:29:51 +0300 (Mon, 17 May 2010) | 1 line


Fix error with everlay windows autoclosing

........

r3364 | mylan | 2010-05-17 18:35:25 +0300 (Mon, 17 May 2010) | 1 line


Fixed link, title and uid data set in refbrowser_setReference

........

r3365 | mylan | 2010-05-17 18:38:15 +0300 (Mon, 17 May 2010) | 1 line


Fix error with everlay windows autoclosing

........

r3366 | mylan | 2010-05-17 18:43:18 +0300 (Mon, 17 May 2010) | 1 line


Fix addReferenceDataGridRowAfter newly added method of dataGridFieldFunctions

........

r3367 | mylan | 2010-05-17 18:46:10 +0300 (Mon, 17 May 2010) | 1 line


Implemented addReferenceDataGridRowAfter method of dataGridFieldFunctions object

........

r3368 | mylan | 2010-05-17 18:47:22 +0300 (Mon, 17 May 2010) | 1 line


Override updateOrderIndex method of dataGridFieldFunctions

........

r3369 | mylan | 2010-05-17 19:14:01 +0300 (Mon, 17 May 2010) | 1 line


Fixed styles toggling on title column edition

........

r3370 | mylan | 2010-05-17 20:35:10 +0300 (Mon, 17 May 2010) | 1 line


Little clean-up

........

r3372 | mylan | 2010-05-18 19:02:12 +0300 (Tue, 18 May 2010) | 1 line


Fix Deprication warning for plone4 consider importing

........

r3373 | mylan | 2010-05-18 19:04:12 +0300 (Tue, 18 May 2010) | 1 line


Added base tests structure, move tests into the tests package

........

r3374 | mylan | 2010-05-18 19:04:51 +0300 (Tue, 18 May 2010) | 1 line


Added installation tests

........

r3375 | mylan | 2010-05-18 20:08:00 +0300 (Tue, 18 May 2010) | 1 line


Fixed package installation, updated demo content creation to MixIn? class

........

r3376 | mylan | 2010-05-18 22:20:41 +0300 (Tue, 18 May 2010) | 1 line


Added basic field test

........

r3377 | mylan | 2010-05-18 23:29:24 +0300 (Tue, 18 May 2010) | 1 line


Added test for link, uid, title for the field

........

r3378 | mylan | 2010-05-19 10:54:46 +0300 (Wed, 19 May 2010) | 1 line


Prevent changing security manager on tested content adding

........

r3379 | mylan | 2010-05-19 13:58:29 +0300 (Wed, 19 May 2010) | 1 line


Added tests for possible bugs in field processing

........

r3380 | mylan | 2010-05-19 13:58:54 +0300 (Wed, 19 May 2010) | 1 line


Updated testing content creation

........

r3381 | mylan | 2010-05-19 13:59:49 +0300 (Wed, 19 May 2010) | 1 line


Simplify field name for example content type

........

r3382 | mylan | 2010-05-19 14:01:16 +0300 (Wed, 19 May 2010) | 1 line


Fixed bug on getting data for uninitialized field

........

r3383 | mylan | 2010-05-19 15:22:37 +0300 (Wed, 19 May 2010) | 1 line


Added tests for widget in view mode

........

r3384 | mylan | 2010-05-19 16:47:06 +0300 (Wed, 19 May 2010) | 1 line


Update comments for TestWidgetView?, some code cleanup

........

r3385 | mylan | 2010-05-19 17:02:29 +0300 (Wed, 19 May 2010) | 1 line


Added TestWidgetEditPresence? tests for presence of columns and buttons in edit mode of the widget

........

r3386 | mylan | 2010-05-19 18:00:01 +0300 (Wed, 19 May 2010) | 1 line


Remove records with links to unexistent objects on getting data from the field

........

r3387 | mylan | 2010-05-19 18:13:57 +0300 (Wed, 19 May 2010) | 1 line


Minor changes

........

r3388 | mylan | 2010-05-19 18:14:42 +0300 (Wed, 19 May 2010) | 1 line


Added tests popup related adapters registration

........

r3389 | mylan | 2010-05-19 19:10:49 +0300 (Wed, 19 May 2010) | 1 line


Added tests for pupup related staff in edit mode of ReferenceDataGridWidget?

........

r3390 | mylan | 2010-05-19 19:12:06 +0300 (Wed, 19 May 2010) | 1 line


Added tests of widget resources

........

r3397 | mylan | 2010-05-19 21:02:51 +0300 (Wed, 19 May 2010) | 1 line


Added MANIFEST.in, updated author in package information

........

Location:
quintagroup.referencedatagridfield/trunk
Files:
1 deleted
9 edited
14 copied

Legend:

Unmodified
Added
Removed
  • quintagroup.referencedatagridfield/trunk

    • Property svnmerge-integrated changed from /quintagroup.referencedatagridfield/branches/plone4:1-3343 to /quintagroup.referencedatagridfield/branches/plone4:1-3398
    • Property svn:mergeinfo set to /quintagroup.referencedatagridfield/branches/plone4:2306-2358
  • quintagroup.referencedatagridfield/trunk/quintagroup/referencedatagridfield/_field.py

    r2300 r2360  
    1313from Products.Archetypes.Registry import registerField, registerWidget 
    1414 
    15 from Products.ATReferenceBrowserWidget.ATReferenceBrowserWidget import ReferenceBrowserWidget 
     15from archetypes.referencebrowserwidget.widget import ReferenceBrowserWidget 
    1616 
    1717from Products.DataGridField.Column import Column 
     
    3333        'macro': "referencedatagridwidget", 
    3434        'helper_css': ('datagridwidget.css','referencedatagridwidget.css'), 
    35         'helper_js': ('referencebrowser.js', 'datagridwidget.js',), 
     35        'helper_js': ('referencebrowser.js', 'datagridwidget.js', 'referencedatagridwidget.js'), 
    3636        'force_close_on_insert': True, 
     37        'popup_name': 'datagridref_popup', 
    3738        'columns': { 
    3839            'title': StyledColumn("Title", trigger_key="default_title", 
     
    138139        rows = DataGridField.get(self, instance, **kwargs) 
    139140        for row in rows: 
     141            uid = row.get("uid","") 
     142            link = row.get("link","") 
     143            title = row.get("title","") 
    140144            result.append({ 
    141145                # DataGridField row data 
    142                 "uid": row["uid"], 
    143                 "link": row["link"], 
    144                 "title": row["title"], 
     146                "uid": uid, "link": link, "title": title, 
    145147                # View data 
    146                 "url": "", 
    147                 "default_title": None}) 
     148                "url": "", "default_title": None}) 
    148149            data = result[-1] 
    149150            # Process remote URL and collect UIDs 
    150             if row["link"]: 
    151                 data["url"] = quote(row["link"], safe='?$#@/:=+;$,&%') 
    152                 data["default_title"] = row["link"] 
     151            if link: 
     152                data["url"] = quote(link, safe='?$#@/:=+;$,&%') 
     153                data["default_title"] = link 
    153154                # if title not set for remote url - set it equals to url 
    154155                if not data["title"]: 
    155156                    data["title"] = data["default_title"] 
    156157            else: 
    157                 uids[row["uid"]] = data 
     158                uids[uid] = data 
    158159        # Process UIDs 
    159160        if uids: 
     
    167168                if not data["title"]: 
    168169                    data["title"] = data["default_title"] 
     170            # Remove records with links to unexistent objects 
     171            del_uids = set(uids.keys()) - set([b.UID for b in brains]) 
     172            result = filter(lambda r: not r["uid"] in del_uids, result) 
    169173 
    170174        return result 
  • quintagroup.referencedatagridfield/trunk/quintagroup/referencedatagridfield/columns.py

    r2300 r2360  
    22 
    33from AccessControl import ClassSecurityInfo 
    4 from Globals import InitializeClass 
     4from App.class_init import InitializeClass 
    55from Products.DataGridField.Column import Column 
    66 
  • quintagroup.referencedatagridfield/trunk/quintagroup/referencedatagridfield/configure.zcml

    r2305 r2360  
    77    i18n_domain="quintagroup.referencedatagridfield"> 
    88 
    9   <!-- add required packages --> 
    10   <include package="Products.ATReferenceBrowserWidget" /> 
     9  <!-- include requirement packages --> 
     10  <include package="archetypes.referencebrowserwidget" /> 
    1111  <include package="Products.DataGridField" /> 
    1212 
    1313  <five:registerPackage package="." initialize=".initialize" /> 
     14 
     15  <include package=".browser" /> 
    1416 
    1517  <cmf:registerDirectory name="skins" directory="skins" recursive="True" /> 
  • quintagroup.referencedatagridfield/trunk/quintagroup/referencedatagridfield/examples/ReferenceDataGridDemoType.py

    r2266 r2360  
    1414    schema = BaseSchema + Schema(( 
    1515 
    16         ReferenceDataGridField('DemoReferenceDataGridField', 
     16        ReferenceDataGridField('demo_rdgf', 
    1717            schemata='default', 
    1818            relationship="demo_relation", 
  • quintagroup.referencedatagridfield/trunk/quintagroup/referencedatagridfield/skins/referencedatagridfield/datagridwidget_manipulators.pt

    r2279 r2360  
    77<body> 
    88 
    9     <metal:define define-macro="edit_manipulators">    
     9    <metal:define define-macro="edit_manipulators" 
     10        tal:define="helper nocall:here/refbrowserhelper; 
     11                    overlay_id string:atrb_${fieldId}"> 
    1012     
    1113         <tal:manipulator-cells> 
     
    2123 
    2224                <td class="datagridwidget-manipulator" 
    23                     tal:define="multiVal      python:0; 
    24                                 fieldRealName field/getName; 
    25                                 "> 
    26                     <div style="clear: both" 
    27                          tal:define="startup_directory python:here.referencebrowser_startupDirectory(widget.getStartupDirectory(here)); 
    28                                      global at_url at_url|python:'/'.join(here.getPhysicalPath()); 
    29                                      field_id string:uid_${fieldId}; 
    30                                      field_link_id string:link_${fieldId}; 
    31                                      field_title_id string:title_${fieldId}; 
    32                                      "> 
    33                         <input type="button" 
    34                                class="searchButton" 
    35                                value="Select" 
    36                                onClick="" 
    37                                i18n:attributes="value label_select;" 
    38                                tal:attributes="onClick string:javascript:referencebrowser_openBrowser('${startup_directory}','${field_id}', '${at_url}', '${fieldRealName}', '${field_title_id}', '${field_link_id}', this)" /> 
    39                     </div> 
     25                    tal:define="multiValued python:0;"> 
     26 
     27                  <div style="clear: both" 
     28                      tal:define=" 
     29                          global at_url at_url|python:'/'.join(here.getPhysicalPath()); 
     30                          startup_directory python:helper.getStartupDirectory(field); 
     31                          field_id string:uid_${fieldId}; 
     32                          field_link_id string:link_${fieldId}; 
     33                          field_title_id string:title_${fieldId}; 
     34                          "> 
     35                    <input type="button" class="searchButton addreference" value="Add..." 
     36                           i18n:attributes="value label_add;" 
     37                           tal:define="popup_width widget/popup_width|string:500; 
     38                                       popup_height widget/popup_height|string:550;" 
     39                           tal:attributes="src string:${startup_directory}/refdatagridbrowser_popup?fieldName=${field_id}&fieldRealName=${field/getName}&at_url=${at_url}&fieldTitleName=${field_title_id}&fieldLinkName=${field_link_id}; 
     40                                       rel string:#${overlay_id}" /> 
     41                       </div><div id="atrb" tal:attributes="id overlay_id" class="overlay overlay-ajax"> 
     42                       <div class="pb-ajax"> 
     43                         <!-- <a href="" i18n:translate="referencebrowser_back" class="refbrowser_back">Back</a> --> 
     44                         <div class="overlaycontent" style="font-size: 125%"></div> 
     45                         <!-- <a href="" i18n:translate="referencebrowser_back" class="refbrowser_back">Back</a> --> 
     46                       </div> 
     47                       </div> 
     48 
    4049                </td> 
    4150 
     
    5059                                " 
    5160                          alt="Add row"   
    52                           onclick="dataGridFieldFunctions.addRowAfter(this); return false"/> 
     61                          onclick="dataGridFieldFunctions.addReferenceDataGridRowAfter(this); return false"/> 
    5362                 </td>                   
    5463 
  • quintagroup.referencedatagridfield/trunk/quintagroup/referencedatagridfield/skins/referencedatagridfield/referencebrowser.js

    r2300 r2360  
    1 // Crossbrowser event listeners adder 
    2 function addEvent(obj, evType, fn, useCap) { 
    3     var r = false; 
    4     if (obj.addEventListener){ 
    5         if (typeof(useCap) == 'undefined') 
    6             useCap = false; 
    7         obj.addEventListener(evType, fn, useCap); 
    8         r = true; 
    9      } 
    10      else if (obj.attachEvent) { 
    11          var id = obj.sourceIndex || -1; 
    12  
    13          if (!fn[evType + id]) { 
    14              var f = fn[evType + id] = function(e) { 
    15                  var o = document.all[id] || document; 
    16                  o._f = fn; 
    17                  var s = o._f(e); 
    18                  o._f = null; 
    19                  return s; 
    20              }; 
    21  
    22              r = obj.attachEvent("on" + evType, f); 
    23              obj = null; 
    24          } 
    25      } 
    26      return r; 
    27  }; 
    28  
    29 function triggerTitleClass(e) { 
    30     var currnode = window.event ? window.event.srcElement : e.currentTarget; 
    31      
    32         // fetch required data structure    
    33     var element = getThisOrParentElement(currnode, "INPUT"); 
    34     // If no input tag found - leave function 
    35     if (element == null || element.tagName.toUpperCase() == "BODY") 
    36         return; 
    37      
    38     var current = element.value; 
    39     var initial = element.getAttribute("default_value"); 
    40     if (initial == null || current == null) 
    41         return; 
    42  
    43     if (initial == current) { 
    44        setClassAttr(element, "not-changed-title-field") 
    45     } else { 
    46        setClassAttr(element, "changed-title-field") 
    47     } 
    48 } 
    49  
    50 function setClassAttr(element, value) { 
    51     if (element.className) { 
    52         element.className = value 
    53     } else { 
    54         element.setAttribute("CLASS", value) 
    55     }  
    56 } 
    57 // Trigger styles on focusing on the element 
    58 function triggerOnFocusStyles(e) { 
    59     var currnode = window.event ? window.event.srcElement : e.currentTarget; 
    60      
    61         // fetch required data structure    
    62     var element = getThisOrParentElement(currnode, "INPUT"); 
    63     // If no input tag found - leave function 
    64     if (element == null || element.tagName.toUpperCase() == "BODY") 
    65         return; 
    66     setClassAttr(element, "changed-title-field") 
    67 } 
    68  
    69 function getThisOrParentElement(currnode, tagname) { 
    70     /* Find the first parent node with the given tag name */ 
    71  
    72     tagname = tagname.toUpperCase(); 
    73     var parent = currnode; 
    74  
    75     while(parent.tagName.toUpperCase() != tagname) { 
    76         parent = parent.parentNode; 
    77         // Next line is a safety belt 
    78         if(parent.tagName.toUpperCase() == "BODY")  
    79             return null; 
    80     } 
    81  
    82     return parent; 
    83 } 
    84  
    85  
    86 // function to open the popup window 
    87 function getOrderIndex(currnode) { 
    88     if (typeof(dataGridFieldFunctions) == "object") { 
    89         var rows = dataGridFieldFunctions.getWidgetRows(currnode); 
    90         var row = dataGridFieldFunctions.getParentElementById(currnode, "datagridwidget-row");       
    91         if(row == null) { 
    92             alert("Couldn't find DataGridWidget row"); 
    93             return; 
    94         } 
    95  
    96         var idx = null 
    97  
    98         // We can't use nextSibling because of blank text nodes in some browsers 
    99         // Need to find the index of the row 
    100         for(var t = 0; t < rows.length; t++) { 
    101             if(rows[t] == row) { 
    102                 idx = t; 
    103                 break; 
    104             } 
    105         } 
    106  
    107         // Abort if the current row wasn't found 
    108         if(idx == null) 
    109             return; 
    110         return idx; 
    111     } 
    112     return; 
    113 } 
    114  
    115 function getOrderedElement(widget_id, order_idx) { 
    116     // First get first element for the current field 
    117     var element=document.getElementById(widget_id); 
    118  
    119     // If it is about DataGridField use it to chose correct element 
    120     if (typeof(dataGridFieldFunctions) == "object" && order_idx >= 0) { 
    121         var rows = dataGridFieldFunctions.getWidgetRows(element); 
    122         if (rows.length >= order_idx) { 
    123             var row = rows[order_idx] 
    124             var inputs = row.getElementsByTagName("input") 
    125             for (var i=0;i<=inputs.length;i++) { 
    126                 if (inputs[i].id == widget_id) { 
    127                     element = inputs[i]; 
    128                     break; 
    129                 } 
     1function prepareRefPopup(context) { 
     2    jq(function() { 
     3 
     4      // the overlay itself 
     5      jq('.addreference', context).overlay({ 
     6           closeOnClick: false, 
     7           onBeforeLoad: function() { 
     8               ov = jq('div#content').data('overlay'); 
     9               // close overlay, if there is one already 
     10               // we only allow one referencebrowser per time 
     11               if (ov) {ov.close(); } 
     12               var wrap = this.getContent().find('.overlaycontent'); 
     13               var src = this.getTrigger().attr('src'); 
     14               var srcfilter = src + ' >*'; 
     15               wrap.data('srcfilter', srcfilter); 
     16               jq('div#content').data('overlay', this); 
     17               resetHistory(); 
     18               wrap.load(srcfilter); 
     19               }, 
     20           onLoad: function() { 
     21               widget_id = this.getTrigger().attr('rel').substring(6); 
     22               disablecurrentrelations(widget_id); 
     23           }}); 
     24 
     25      // the breadcrumb-links and the links of the 'tree'-navigation 
     26      jq('[id^=atrb_] a.browsesite', context).live('click', function(event) { 
     27          var target = jq(this); 
     28          var src = target.attr('href'); 
     29          var wrap = target.parents('.overlaycontent'); 
     30          var srcfilter = src + ' >*'; 
     31          pushToHistory(wrap.data('srcfilter')); 
     32          wrap.data('srcfilter', srcfilter); 
     33          // the history we are constructing here is destinct from the 
     34          // srcfilter-history. here we construct a selection-widget, which 
     35          // is available, if the history_length-parameter is set on the widget 
     36          // the srcfilter-history is used for storing the URLs to make the 
     37          // 'Back'-link work. 
     38          var newoption = '<option value="' + src + '">' + target.attr('rel') + '</option>'; 
     39          refreshOverlay(wrap, srcfilter, newoption); 
     40          return false; 
     41          }); 
     42 
     43      // the links for inserting referencens 
     44      jq('[id^=atrb_] input.insertreference', context).live('click', function(event) { 
     45          var target = jq(this); 
     46          var wrap = target.parents('.overlaycontent'); 
     47          var fieldname = wrap.find('input[name=fieldName]').attr('value'); 
     48          var fieldtitle = wrap.find('input[name=fieldTitleName]').attr('value'); 
     49          var fieldlink = wrap.find('input[name=fieldLinkName]').attr('value'); 
     50          var multi = wrap.find('input[name=multiValued]').attr('value'); 
     51          var close_window = wrap.find('input[name=close_window]').attr('value'); 
     52          var title = target.parents('tr').find('img').attr('alt'); 
     53          var linkpath = target.parents('tr').find('img').attr('rel'); 
     54          var active_tr = wrap.parents('tr[id=datagridwidget-row]'); 
     55          var uid = target.attr('rel'); 
     56          refbrowser_setReference(fieldname, uid, title, parseInt(multi), 
     57                                  active_tr, fieldtitle, title, fieldlink, linkpath); 
     58          if (close_window === '1') { 
     59              overlay = jq('div#content').data('overlay'); 
     60              overlay.close(); 
     61          } else { 
     62              showMessage(title); 
     63          }; 
     64          jq(this).attr('disabled', 'disabled'); 
     65          }); 
     66 
     67 
     68      // the history menu 
     69      jq('[id^=atrb_] form#history select[name=path]', context).live('change', function(event) { 
     70          var target = jq(this); 
     71          var wrap = target.parents('.overlaycontent'); 
     72          src = jq('[id^=atrb_] form#history select[name=path] :selected', this).attr('value'); 
     73          var srcfilter = src + ' >*'; 
     74          refreshOverlay(wrap, srcfilter, ''); 
     75          return false; 
     76          }); 
     77 
     78      // the search form 
     79      jq('[id^=atrb_] form#search input[name=submit]', context).live('click', function(event) { 
     80          var target = jq(this); 
     81          var src = target.parents('form').attr('action'); 
     82          var wrap = target.parents('.overlaycontent'); 
     83          var fieldname = wrap.find('input[name=fieldName]').attr('value'); 
     84          var fieldtitle = wrap.find('input[name=fieldTitleName]').attr('value'); 
     85          var fieldlink = wrap.find('input[name=fieldLinkName]').attr('value'); 
     86          var fieldrealname = wrap.find('input[name=fieldRealName]').attr('value'); 
     87          var at_url = wrap.find('input[name=at_url]').attr('value'); 
     88          var searchvalue = wrap.find('input[name=searchValue]').attr('value'); 
     89          var multi = wrap.find('input[name=multiValued]').attr('value'); 
     90          var close_window = wrap.find('input[name=close_window]').attr('value'); 
     91          qs = 'searchValue=' + searchvalue + '&fieldRealName=' + fieldrealname + 
     92            '&fieldName=' + fieldname + '&multiValued=' + multi + 
     93            '&close_window=' + close_window + '&at_url=' + at_url + 
     94            '&fieldTitleName=' + fieldtitle + '&fieldLinkName=' + fieldlink; 
     95          var srcfilter = src + '?' + qs + ' >*'; 
     96          pushToHistory(wrap.data('srcfilter')); 
     97          wrap.data('srcfilter', srcfilter); 
     98          refreshOverlay(wrap, srcfilter, ''); 
     99          return false; 
     100          }); 
     101 
     102    }); 
     103}; 
     104 
     105jq(document).ready(function(){ 
     106    prepareRefPopup(this); 
     107}); 
     108jq.fn.prepRefPopup = function() { 
     109    prepareRefPopup(this); 
     110}; 
     111 
     112function disablecurrentrelations (widget_id) { 
     113   jq('ul#' + widget_id + ' :input').each( 
     114       function (intIndex) { 
     115         uid = jq(this).attr('value'); 
     116         cb = jq('input[rel=' + uid + ']'); 
     117         cb.attr('disabled', 'disabled'); 
     118         cb.attr('checked', 'checked'); 
     119       }); 
     120} 
     121 
     122// function to return a reference from the popup window back into the widget 
     123function refbrowser_setReference(widget_id, uid, label, multi, 
     124                                 active_tr, widget_title_id, link_title, 
     125                                 widget_link_id, link_path) 
     126{ 
     127    var element = null, 
     128        label_element = null, 
     129        current_values = null, 
     130        i = null, 
     131        list = null, 
     132        li = null, 
     133        input = null, 
     134        up_element = null, 
     135        down_element = null, 
     136        container = null; 
     137 
     138    if (typeof(active_tr) != "undefined") { 
     139        // Update Uid field 
     140        jq('#' + widget_id, active_tr).attr("value", uid); 
     141        // Update title field 
     142        title = jq('#' + widget_title_id, active_tr); 
     143        title.attr("value", link_title); 
     144        title.addClass("not-changed-title-field"); 
     145        title.attr("default_value", link_title); 
     146        title.blur(triggerTitleClass); 
     147        title.focus(triggerOnFocusStyles); 
     148        // Update link field 
     149        link = jq('#' + widget_link_id, active_tr); 
     150        link.attr('readonly', false); 
     151        link.attr('value', link_path); 
     152        link.attr('readonly', true); 
     153        link.addClass("hidden-field"); 
     154 
     155    } else if (multi === 0) { 
     156        // differentiate between the single and mulitselect widget 
     157        // since the single widget has an extra label field. 
     158        jq('#' + widget_id).attr('value', uid); 
     159        jq('#' + widget_id + '_label').attr('value', label); 
     160    }  else { 
     161        // check if the item isn't already in the list 
     162        current_values = jq('#' + widget_id + ' input'); 
     163        for (i = 0; i < current_values.length; i++) { 
     164            if (current_values[i].value === uid) { 
     165                return false; 
    130166            } 
    131167        } 
    132     } 
    133     return element; 
    134 } 
    135  
    136  
    137 function referencebrowser_openBrowser(path, fieldName, at_url, fieldRealName, fieldTitleName, fieldLinkName, currnode) { 
    138     var url = path + '/referencebrowser_popup?fieldName=' + fieldName + '&fieldRealName=' + fieldRealName +'&at_url=' + at_url; 
    139  
    140     var order_idx = getOrderIndex(currnode); 
    141     url += (order_idx)? '&order_idx=' + order_idx: ""; 
    142     url += (typeof(fieldTitleName) != 'undefined')? '&fieldTitleName=' + fieldTitleName: ""; 
    143     url += (typeof(fieldLinkName) != 'undefined')? '&fieldLinkName=' + fieldLinkName: ""; 
    144  
    145     atrefpopup = window.open(url, 'referencebrowser_popup','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=500,height=550'); 
    146 } 
    147  
    148 // function for Array detecting 
    149 function typeOf(value) { 
    150     var s = typeof value; 
    151     if (s === 'object') { 
    152         if (value) { 
    153             if (value instanceof Array) { 
    154                 s = 'array'; 
     168        // now add the new item 
     169        list = document.getElementById(widget_id); 
     170        // add ul-element to DOM, if it is not there 
     171        if (list === null) { 
     172            container = jq('#archetypes-fieldname-' + widget_id + ' input + div'); 
     173            if (!container.length) { 
     174                // fix for Plone 3.3 collections, with a weird widget-id 
     175                container = jq('#archetypes-fieldname-value input + div'); 
    155176            } 
    156         } else { 
    157             s = 'null'; 
    158         } 
    159     } 
    160     return s; 
    161 } 
    162  
    163 // function to return a reference from the popup window back into the widget 
    164 function referencebrowser_setReference(widget_id, uid, label, multi, order_idx, widget_title_id, link_title, widget_link_id, link_path) 
    165 { 
    166     if (order_idx >= 0) { 
    167         // process ReferenceDataGridField 
    168         uid_element=getOrderedElement(widget_id, order_idx); 
    169         uid_element.value=uid; 
    170         title_element=getOrderedElement(widget_title_id, order_idx); 
    171         title_element.value=link_title; 
    172         title_element.className="not-changed-title-field"; 
    173         title_element.setAttribute("default_value", link_title); 
    174         addEvent(title_element, 'blur', triggerTitleClass, false) 
    175         addEvent(title_element, 'focus', triggerOnFocusStyles, false) 
    176         link_element=getOrderedElement(widget_link_id, order_idx); 
    177         link_element.readOnly=false; 
    178         link_element.value=link_path; 
    179         link_element.readOnly=true; 
    180         link_element.className="hidden-field" 
    181     } else if (multi==0) { 
    182         // differentiate between the single and mulitselect widget 
    183         // since the single widget has an extra label field. 
    184         element=document.getElementById(widget_id); 
    185         label_element=document.getElementById(widget_id + '_label'); 
    186         element.value=uid; 
    187         label_element.value=label; 
    188     } else { 
    189          // check if the item isn't already in the list 
    190          var current_values = cssQuery('#' + widget_id + ' input'); 
    191          for (var i=0; i < current_values.length; i++) { 
    192             if (current_values[i].value == uid) { 
     177            container.after( 
     178               '<ul class="visualNoMarker" id="' + widget_id + '"></ul>'); 
     179            list = document.getElementById(widget_id); 
     180        } 
     181        li = document.createElement('li'); 
     182        label_element = document.createElement('label'); 
     183        input = document.createElement('input'); 
     184        input.type = 'checkbox'; 
     185        input.value = uid; 
     186        input.checked = true; 
     187        input.name = widget_id + ':list'; 
     188        label_element.appendChild(input); 
     189        label_element.appendChild(document.createTextNode(' ' + label)); 
     190        li.appendChild(label_element); 
     191        li.id = 'ref-' + widget_id + '-' + current_values.length; 
     192 
     193        sortable = jq('input[name=' + widget_id + '-sortable]').attr('value'); 
     194        if (sortable === '1') { 
     195          up_element = document.createElement('a'); 
     196          up_element.title = 'Move Up'; 
     197          up_element.innerHTML = '&#x25b2;'; 
     198          up_element.onclick = function () { 
     199              refbrowser_moveReferenceUp(this); 
    193200              return false; 
    194             } 
    195           }          
    196           // now add the new item 
    197           list=document.getElementById(widget_id); 
    198           li = document.createElement('li'); 
    199           label_element = document.createElement('label'); 
    200           input = document.createElement('input'); 
    201           input.type = 'checkbox'; 
    202           input.value = uid; 
    203           input.checked = true; 
    204           input.name = widget_id + ':list'; 
    205           label_element.appendChild(input); 
    206           label_element.appendChild(document.createTextNode(label)); 
    207           li.appendChild(label_element); 
    208           list.appendChild(li); 
    209           // fix on IE7 - check *after* adding to DOM 
    210           input.checked = true; 
     201          }; 
     202 
     203          li.appendChild(up_element); 
     204 
     205          down_element = document.createElement('a'); 
     206          down_element.title = 'Move Down'; 
     207          down_element.innerHTML = '&#x25bc;'; 
     208          down_element.onclick = function () { 
     209              refbrowser_moveReferenceDown(this); 
     210              return false; 
     211          }; 
     212 
     213          li.appendChild(down_element); 
     214        } 
     215        list.appendChild(li); 
     216 
     217        // fix on IE7 - check *after* adding to DOM 
     218        input.checked = true; 
    211219    } 
    212220} 
     
    214222// function to clear the reference field or remove items 
    215223// from the multivalued reference list. 
    216 function referencebrowser_removeReference(widget_id, multi) 
     224function refbrowser_removeReference(widget_id, multi) 
    217225{ 
     226    var x = null, 
     227        element = null, 
     228        label_element = null, 
     229        list = null; 
     230 
    218231    if (multi) { 
    219         list=document.getElementById(widget_id) 
    220         for (var x=list.length-1; x >= 0; x--) { 
    221           if (list[x].selected) { 
    222             list[x]=null; 
    223           } 
    224         } 
    225         for (var x=0; x < list.length; x++) { 
    226             list[x].selected='selected'; 
    227           }         
     232        list = document.getElementById(widget_id); 
     233        for (x = list.length - 1; x >= 0; x--) { 
     234            if (list[x].selected) { 
     235                list[x] = null; 
     236            } 
     237        } 
     238        for (x = 0; x < list.length; x++) { 
     239            list[x].selected = 'selected'; 
     240        } 
    228241    } else { 
    229         element=document.getElementById(widget_id); 
    230         label_element=document.getElementById(widget_id + '_label'); 
    231         label_element.value = ""; 
    232         element.value=""; 
    233     } 
    234 } 
    235  
    236  
     242        jq('#' + widget_id).attr('value', ""); 
     243        jq('#' + widget_id + '_label').attr('value', ""); 
     244    } 
     245} 
     246 
     247function refbrowser_moveReferenceUp(self) 
     248{ 
     249    var elem = self.parentNode, 
     250        eid = null, 
     251        pos = null, 
     252        widget_id = null, 
     253        newelem = null, 
     254        prevelem = null, 
     255        arrows = null, 
     256        cbs = null; 
     257    if (elem === null) { 
     258        return false; 
     259    } 
     260    eid = elem.id.split('-'); 
     261    pos = eid.pop(); 
     262    if (pos === 0) { 
     263        return false; 
     264    } 
     265    widget_id = eid.pop(); 
     266    newelem = elem.cloneNode(true); 
     267 
     268    //Fix: (IE keep the standard value) 
     269    cbs = newelem.getElementsByTagName("input"); 
     270    if (cbs.length > 0) { 
     271        cbs[0].checked = elem.getElementsByTagName("input")[0].checked; 
     272    } 
     273 
     274    prevelem = document.getElementById('ref-' + widget_id + '-' + (pos - 1)); 
     275 
     276    // up arrow 
     277    arrows = newelem.getElementsByTagName("a"); 
     278    arrows[0].onclick = function () { 
     279        refbrowser_moveReferenceUp(this); 
     280    }; 
     281    // down arrow 
     282    arrows[1].onclick = function () { 
     283        refbrowser_moveReferenceDown(this); 
     284    }; 
     285 
     286    elem.parentNode.insertBefore(newelem, prevelem); 
     287    elem.parentNode.removeChild(elem); 
     288    newelem.id = 'ref-' + widget_id + '-' + (pos - 1); 
     289    prevelem.id = 'ref-' + widget_id + '-' + pos; 
     290} 
     291 
     292function refbrowser_moveReferenceDown(self) 
     293{ 
     294    var elem = self.parentNode, 
     295        eid = null, 
     296        pos = null, 
     297        widget_id = null, 
     298        current_values = null, 
     299        newelem = null, 
     300        nextelem = null, 
     301        cbs = null, 
     302        arrows = null; 
     303    if (elem === null) { 
     304        return false; 
     305    } 
     306    eid = elem.id.split('-'); 
     307    pos = parseInt(eid.pop(), 10); 
     308    widget_id = eid.pop(); 
     309    current_values = jq('#' + widget_id + ' input'); 
     310    if ((pos + 1) === current_values.length) { 
     311        return false; 
     312    } 
     313 
     314    newelem = elem.cloneNode(true); 
     315    //Fix: (IE keep the standard value) 
     316    cbs = newelem.getElementsByTagName("input"); 
     317    if (cbs.length > 0) { 
     318        cbs[0].checked = elem.getElementsByTagName("input")[0].checked; 
     319    } 
     320 
     321    // up img 
     322    arrows = newelem.getElementsByTagName("a"); 
     323    arrows[0].onclick = function () { 
     324        refbrowser_moveReferenceUp(this); 
     325    }; 
     326    // down img 
     327    arrows[1].onclick = function () { 
     328        refbrowser_moveReferenceDown(this); 
     329    }; 
     330 
     331    nextelem = document.getElementById('ref-' + widget_id + '-' + (pos + 1)); 
     332 
     333    elem.parentNode.insertBefore(newelem, nextelem.nextSibling); 
     334    elem.parentNode.removeChild(elem); 
     335    newelem.id = 'ref-' + widget_id + '-' + (pos + 1); 
     336    nextelem.id = 'ref-' + widget_id + '-' + pos; 
     337} 
     338 
     339function showMessage(message) { 
     340    jq('#messageTitle').text(message); 
     341    jq('#message').show(); 
     342} 
     343 
     344function submitHistoryForm() { 
     345     var form = document.history; 
     346     var path = form.path.options[form.path.selectedIndex].value; 
     347     form.action = path; 
     348     form.submit(); 
     349} 
     350 
     351function pushToHistory(url) { 
     352  var history = jq(document).data('atrb_history'); 
     353  history.push(url); 
     354  jq(document).data('atrb_history', history); 
     355} 
     356 
     357function resetHistory() { 
     358  jq(document).data('atrb_history', []); 
     359} 
     360 
     361function popFromHistory() { 
     362  var history = jq(document).data('atrb_history'); 
     363  value = history.pop(); 
     364  jq(document).data('atrb_history', history); 
     365  return value; 
     366} 
     367 
     368function refreshOverlay(wrap, srcfilter, newoption) { 
     369    var oldhistory = jq('[id^=atrb_] form#history select'); 
     370    wrap.load(srcfilter, function() {  
     371        jq('[id^=atrb_] form#history select').append(newoption + oldhistory.html()); 
     372        ov = jq('div#content').data('overlay'); 
     373        widget_id = ov.getTrigger().attr('rel').substring(6); 
     374        disablecurrentrelations(widget_id); 
     375        }); 
     376} 
  • quintagroup.referencedatagridfield/trunk/quintagroup/referencedatagridfield/skins/referencedatagridfield/referencedatagridwidget.pt

    r2296 r2360  
    7070                     
    7171                        <tal:empty-row tal:define="newRow python: True"> 
    72                                 <tal:template metal:use-macro="here/datagridwidget_edit_row/macros/edit_empty_row"/>                     
     72                                <tal:template metal:use-macro="here/datagridwidget_edit_row/macros/edit_empty_row"/> 
    7373                        </tal:empty-row>                                 
    7474                 </tbody> 
     
    7777            <a class="referencedatagridwidget-add-button" id="datagridwidget-add-button" 
    7878                           tal:condition="field/allow_insert" 
    79                    tal:attributes='onclick python: "dataGridFieldFunctions.addRow(\"" + field.getName() + "\")"'>Add new</a> 
     79                   tal:attributes='onclick python: "dataGridFieldFunctions.addReferenceDataGridRow(\"" + field.getName() + "\")"'>Add new</a> 
    8080 
    8181                        <tal:comment replace="nothing"> 
  • quintagroup.referencedatagridfield/trunk/setup.py

    r2305 r2360  
    22import os 
    33 
    4 version = '0.1' 
     4version = '0.2' 
    55 
    66setup(name='quintagroup.referencedatagridfield', 
     
    1616        ], 
    1717      keywords='ReferenceField DataGridField Archetypes', 
    18       author='Quintagroup', 
     18      author='Quintagroup [Andriy Mylenkyi]', 
    1919      author_email='talk@quintagroup.com', 
    2020      url='http://svn.quintagroup.com/products/quintagroup.referencedatagridfield', 
     
    2626      install_requires=[ 
    2727          'setuptools', 
    28           'Products.DataGridField==1.6.1', 
    29           # 'Products.ATReferenceBrowserWidget==2.0.5', 
     28          'Products.DataGridField>=1.8a1', 
     29          'archetypes.referencebrowserwidget>=2.0a', 
     30          # 'Products.ATReferenceBrowserWidget>=3.0a', 
    3031          # -*- Extra requirements: -*- 
    3132      ], 
Note: See TracChangeset for help on using the changeset viewer.