Jump to content

Batch Child Editor


adrian

Recommended Posts

Now I have tested it with the browser console. As you can see, there are no JS-errors:

Screenshot_9.thumb.jpg.5a554b1f772a403abcb8a7aedde8e3b2.jpg

In line 165 of the BatchChildEditor.js the checkbox markup will be declared:

bce_toggleControl = '<input type="checkbox" class="' + bce_columnControlClass + '" style="position: relative; top: 2px; margin-right: 4px;" />',

But this markup will not be added next to tableheader cells.

I havent been working with the browser console so far. Maybe I am doing something wrong or I am in the wrong part of the console, but I cannot find an error.

  • Like 1
Link to comment
Share on other sites

Thanks - a script can fail even if there are no errors, eg. in this case probably the markup can't be added because the target element is not found in the DOM (maybe the selector used doesn't match anything). It's hard to tell anything else without seeing it. I would try using console.log(obj.length); where object is the target (jQuery) element. If it's 1 (shown in the console) then it's there, otherwise not.

  • Like 1
Link to comment
Share on other sites

OK I have tried the following:

I have added the following  script to the admin.php file

<script type="text/javascript">
a = "test";
console.log(a.length);
obj = bce_toggleControl;
console.log(obj.length);
</script>

The variable a with the content "test" is only to check if the console.log works.

I got the following output:

Screenshot_22.jpg.93a15132b914379bfad097b76e23dd0e.jpg

As you can see the variable "a" has a length of 4 - this is correct.

But the variable "bce_toggleControl" which is responsible for the checkbox doesnt return anything.

I have also tried it with bce_fieldID depending on this snippet

    // add column controls (top, bottom and replace modes)
    $(document).on('loaded', '#' + bce_fieldID, function () {
        addBceColumnControls();
    });

Same result

  • Like 1
Link to comment
Share on other sites

Of course :)

Here is what I have added:

        a = "test";
        console.log(a,length);
        console.log(bce_fieldID,length);

   // add column controls (top, bottom and replace modes)
    $(document).on('loaded', '#' + bce_fieldID, function () {
        addBceColumnControls();
    });

And this is what I got:

Screenshot_24.jpg.081992a4f4ac6670d4afbb8a7a75f12e.jpg

As you can see the variable "bce_fieldsetID" consist of 23 letters (= ProcessPageEditChildren)

So this variable of the if statement is there!!!

  • Like 1
Link to comment
Share on other sites

What I have found out is the following.

In the JS-file there is the part where the additional function will be created (approx. at line 218)

    function addBceColumnControls() {
         
        //this timeout is a bit of a hack that should be improved in the future
        setTimeout(function () {

            if (bce_isColumnControlsAdded) {
                return false;
            }

            if ($(bce_adminDataTableSelector).length === 0) {
                return false;
            }

            // do not add controls if there is no more than 1 row
            if ($(bce_adminDataTableSelector + ' tbody tr').length <= 1) {
                return false;
            }

            //$(bce_adminDataTableSelector + ' tbody').on('click', 'input[type="checkbox"], i.InputfieldChildTableRowDeleteLink', function () {
            $(bce_adminDataTableSelector + ' tbody').on('click', 'input[type="checkbox"]', function () {
                setColumnControlStates($(this));
            });
            
            // add new controls
            for (var i = 0; i < bce_allowedColumnControls.length; i++) {

                var currentControl = bce_allowedColumnControls[i];

                // skip non-existing elements
                if (!$(currentControl).length) {
                    continue;
                }

                // get index of first checkbox in the first row
                var index = $(bce_adminDataTableSelector + ' ' + currentControl + ':eq(0)').parent().index();

                // do the add
                $(bce_adminDataTableSelector + ' th:eq(' + index + ')').prepend($(bce_toggleControl));

                // set initial checkbox states
                setColumnControlStates($(bce_adminDataTableSelector + ' th:eq(' + index + ') input'));

                // add event
                addColumnControlEvent(bce_adminDataTableSelector, currentControl, index);
            }

            // disable thead break to multiline
            $(bce_adminDataTableSelector + ' thead').css('white-space', 'nowrap');

            bce_isColumnControlsAdded = true;

            return true;

        }, 1000);

    }

There are a lot of if-statements depending on the length of a variable.

It is not possible to log the variables inside this function. Fe. if I want to check the variable length of the second if statement

if ($(bce_adminDataTableSelector).length === 0) {
                return false;
            }

with console.log(bce_adminDataTableSelector.length); or console.log($(bce_adminDataTableSelector).length); nothing will be returned, so maybe the if-statements doesnt work in this case.

  • Like 1
Link to comment
Share on other sites

Yepp, the main goal would be to detect where it stops at your side :) 

Btw "variable length" in these cases are the number of items found in the DOM. So if it's 0 for "$(bce_adminDataTableSelector).length" it means the html tag is not found in the DOM.

I guess you can't provide login details via PM, that would make things easier :) 

  • Like 1
Link to comment
Share on other sites

Thank you both for getting to the bottom of this!

@tpr - I did tweak your changes slightly to use "one" and "mouseover":

    $(document).one('mouseover', bce_adminDataTableSelector, function () {

instead of "on" and "hover":

    $(document).on('hover', bce_adminDataTableSelector, function () {

so that it's triggered only once. I know you had another check in there to see if the controls were already added, but I still think this an improvement. Do you see any issues with this change?

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Hi,

I'm using PW 3.0.61  with PHP7 and yesterday I downloaded this module as I urgently need to import coordinates to link those pages to my map in the frontend.  As I'm using  Leaflet Map Marker in the admin, the subfields in the 'map' table in the database are:

map.data map.lat map.lng map.zoom map.status
e.g. Albatrosstraat, Knokke-Heist, BE 51.34085 3.242333 18

-100

As I have to import 1000's of pages, I have no option but to work by batch georefferring and csv imports.

I tried everything to make the import of the subfields work but to no avail. Could it be that the module is not compatible with PW 3.0.61  or that Leaflet Map Marker has other settings, or am I missing something somewhere?

I tried to pair CSV column number and Processwire field names as in:

1:title
2:
map.data (tried map.address too)
3:map.lat
4.map:lng etc. 

 

 

Link to comment
Share on other sites

  • 2 weeks later...

I am trying to import several child pages using a cvs file. All normal field types are importing without a problem, but when importing 'ProFields Textareas' fields, these fields are not being populated with the specified data form the CSV file.

My Textareas field type is named “chartNumbers”, which contains 3 ‘Textarea Definitions’: “fieldfrom”, “fieldto”, fieldsplit”.

I have written the ‘CSV filed pairings’ in my page settings like this:

1:title
2:page_shorttitle
3:page_subtitle
4:page_summary
5:chartNumbers.fieldfrom
6:chartNumbers.fieldto
7:chartNumbers.fieldsplit

I believe that the above field parings are correct based on what I read in this post .

Having spent almost 5-hours trying to figure this out, my brain has decided to give up at 5:30am.

Can anybody tell me what I’m doing incorrect (if that is the case), or help me figure out what is going wrong.


My setup:  PW v3.0.61 Master, ProFields Textareas v0.0.7,  Batch Child Editor v1.6.6

Link to comment
Share on other sites

On 12/05/2017 at 5:38 AM, CodeCoffeeCode said:

My setup:  PW v3.0.61 Master, ProFields Textareas v0.0.7,  Batch Child Editor v1.6.6

Ive just updated to PW v3.0.62.  As Pretobrazza mentioned on May 3rd in this post, I think there maybe a compatibility issue with this module when trying to import 'ProFields Textareas - Textarea Definitions' fields.

Any help would be useful. It is impossible to import these fields using the 'Import pages from CSV' module,  I've several hundred pages to import that require these fields populating.

Link to comment
Share on other sites

hi codecoffeecode,

you can try to use something like my solution for your import if you are only doing the import once (and not need your users to be able to import anything). it's very easy to import all kinds of data like this. adrian will be offline for some weeks...

hope that helps ;)

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Hi @Pretobrazza and @CodeCoffeeCode - I am sorry for the very long delay in responding - I have just returned from an extended time away from my computer.

It looks like the issues you were having with textareas fields and the map marker were actually due to PHP 7. The latest version should fix things - I tested with textareas which now work perfectly again - hopefully map marker fields will also work again now.

I have also fixed some other issues with adding multiple new child in Edit mode and also taken care of this issue.

Please let me know how things work for you now.

  • Like 3
Link to comment
Share on other sites

  • 2 weeks later...

Adrian, let me first say "thank you so much" for this great module - it's incredibly helpful.

I think I have found a small bug. When one or more quotes are used in the title of the page, the "edit" section breaks, see attached screenshot. I have now seen this across different installations, so I think it hasn't to do with my setup.

Batch Child Editor is latest version 1.6.7, ProcessWire is 3.0.65

screenshot.thumb.png.cbb81380f4f777a84bce9f68844de2cf.png

  • Like 1
Link to comment
Share on other sites

Just ran into a funny problem.
Well... not really funny, but it took me way too long to figure it out. (Sometimes I wonder how get through the day...)

I am developing the migration of 10+ similar sites from another CMS to PW. All the websites have lots of fields and data, and BCE is the only way to map the data to textareas subfileds. All tests worked great so far until now!

Suddenly I was unable to input my fieldpairings. 

ProcessWire: ProcessPageEdit: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'data' at row 1

As I said it took me way too long to realize the "Data too long for column data"

During my testing the database field 'data' got filled up with all the settings for all the parent pages, and since it is of type text, I guess 64kb is the limit.

I had to uninstall and reinstall BCE to start over with an empty data field.

I guess there is no real solution to this but I wanted to add it here in case somebody faces the same dilemma.

  • Like 2
Link to comment
Share on other sites

@Klenkes - a simple solution to this would be for you to manually change the "data" field in the "modules" db table from "text" to "mediumtext". I'll see if I can get Ryan to do it in the core so it's always available.

https://github.com/processwire/processwire-issues/issues/321

Edited by adrian
Added link to new Github issue
  • Like 2
Link to comment
Share on other sites

I thought about mediumtext but don't know what "unwanted" effect it may have on other PW functions.

I went the even more simple way and import now to a single import page, and then move the imported pages with your great AdminActions to their destination parents. This way I don't have to configure all parent pages with my fieldpairings.

BTW... thank you very much for AdminActions. Without Move and Search and Replace this project wouldn't be possible.

  • Like 4
Link to comment
Share on other sites

Me again... I imported a few hundred pages to more than 30 parents and almost everthing is fine.

Then I noticed that all custom ids and classes in my imported textareas were filtered out during save, even with deactivated ACF and HTML Purifier(in textareas settings) Pasting in the same HTML in source mode afterwards leaves the custum stuff alone. So it works.

I don't even know wether it's a BCE issue or with Profields textareas? This problem seems familiar but I can't remember...

  • Like 1
Link to comment
Share on other sites

7 hours ago, Klenkes said:

Me again... I imported a few hundred pages to more than 30 parents and almost everthing is fine.

Then I noticed that all custom ids and classes in my imported textareas were filtered out during save, even with deactivated ACF and HTML Purifier(in textareas settings) Pasting in the same HTML in source mode afterwards leaves the custum stuff alone. So it works.

I don't even know wether it's a BCE issue or with Profields textareas? This problem seems familiar but I can't remember...

I do use the $sanitizer->purify option with all content added via BCE, so that will be the source of the problem for sure. I can see two possible options here.

1) Add a BCE config setting to enable you to turn off the purifier sitewide and/or per parent page.
2) Check the purifier status for the field that the content is being added to and respect that.

Any thoughts?

PS if you want a quick fix, just edit this line:
https://github.com/adrianbj/BatchChildEditor/blob/ba228d2f011d306345f02ec4aa19d090f2d89481/BatchChildEditor.module#L1448

Link to comment
Share on other sites

That explains a lot ;)

For the sites I migrate to PW option 1 would me my choice, because importing the content is the first priority and editing the content comes later. Nobody wants to sift through a few hundred pages to make it all like it was. In my case editors are skilled, trusted and would be fired if they do monkeybusiness with the HTML.

...but then again... option 2 would work as well since I already deactivated all the purifier options for the fields anyway.

For now I will go with the dirty fix >:D

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By MarkE
      This fieldtype and inputfield bundle was built for storing measurement values within a field, rendering them in a variety of formats and converting them to other units or otherwise modifying them via the API.
      The API consists of a number of predefined functions, some of which include...
      render() for rendering the measurement object, valueAs() for converting the value to another unit value, convertTo() for converting the whole measurement object to different units, and add() and subtract() for for modifying the stored value by the value (converted as required) in another measurement. In the admin the inputfield includes a checkbox (which can be optionally disabled) for converting values on page save. For an example if a value was typed in as centimeters, the unit was changed to metres, and the page saved with this checkbox selected, said value would be automatically converted so that e.g. 170 cm becomes 1.7 m.

      A simple length field using Fieldtype Measurement and Inputfield Measurement.
      Combination units (e.g. feet and inches) are also supported.
      Please note that this module is 'proof of concept' at the moment - there are limited units available and quite a lot of code tidying to do. More units will be added shortly.
      See the GitHub at https://github.com/MetaTunes/FieldtypeMeasurement for full details and updates.
    • By tcnet
      File Manager for ProcessWire is a module to manager files and folders from the CMS backend. It supports creating, deleting, renaming, packing, unpacking, uploading, downloading and editing of files and folders. The integrated code editor ACE supports highlighting of all common programming languages.
      https://github.com/techcnet/ProcessFileManager

      Warning
      This module is probably the most powerful module. You might destroy your processwire installation if you don't exactly know what you doing. Be careful and use it at your own risk!
      ACE code editor
      This module uses ACE code editor available from: https://github.com/ajaxorg/ace

      Dragscroll
      This module uses the JavaScript dragscroll available from: http://github.com/asvd/dragscroll. Dragscroll adds the ability to drag the table horizontally with the mouse pointer.
      PHP File Manager
      This module uses a modified version of PHP File Manager available from: https://github.com/alexantr/filemanager
       
    • By tcnet
      This module implements the website live chat service from tawk.to. Actually the module doesn't have to do much. It just need to inserted a few lines of JavaScript just before the closing body tag </body> on each side. However, the module offers additional options to display the widget only on certain pages.
      Create an account
      Visit https://www.tawk.to and create an account. It's free! At some point you will reach a page where you can copy the required JavaScript-code.

      Open the module settings and paste the JavaScript-code into the field as shown below. Click "Submit" and that's all.

      Open the module settings
      The settings for this module are located int the menu Modules=>Configure=>LiveChatTawkTo.

       
    • By tcnet
      Session Viewer is a module for ProcessWire to list session files and display session data. This module is helpful to display the session data of a specific session or to kick out a logged in user by simply delete his session file. After installation the module is available in the Setup menu.

      The following conditions must be met for the module to work properly:
      Session files
      Session data must be stored in session files, which is the default way in ProcessWire. Sessions stored in the database are not supported by this module. The path to the directory where the session files are stored must be declared in the ProcessWire configuration which is by default: site/assets/sessions.
      Serialize handler
      In order to transform session data easier back to a PHP array, the session data is stored serialized. PHP offers a way to declare a custom serialize handler. This module supports only the default serialize handlers: php, php_binary and php_serialize. WDDX was dropped in PHP 7.4.0 and is therefore not supported by this module as well as any other custom serialize handler. Which serialize handler is actually used you can find out in the module configuration which is available under Modules=>Configure=>SessionViewer.

      Session data
      The session data can be displayed in two different ways. PHP's default output for arrays print_r() or by default for this module nice_r() offered on github: https://github.com/uuf6429/nice_r. There is a setting in the module configuration if someone prefers print_r(). Apart from the better handling and overview of the folded session data the output of nice_r() looks indeed nicer.

      Links
      ProcessWire module directory
      github.com
    • By Robin S
      Repeater Easy Sort
      Adds a compact "easy-sort" mode to Repeater and Repeater Matrix, making those fields easier to sort when there are a large number of items.
      The module also enhances Repeater Matrix by allowing a colour to be set for each matrix type. This colour is used in the item headers and in the "add new" links, to help visually distinguish different matrix types in the inputfield.
      Screencasts
      A Repeater field

      A Repeater Matrix field with custom header colours

      Easy-sort mode
      Each Repeater/Matrix item gets an double-arrow icon in the item header. Click this icon to enter easy-sort mode.
      While in easy-sort mode:
      The items will reduce in width so that more items can be shown on the screen at once. The minimum width is configurable in the field settings. Any items that were in an open state are collapsed, but when you exit easy-sort mode the previously open items will be reopened. You can drag an item left/right/up/down to sort it within the items. The item that you clicked the icon for is shown with a black background. This makes it easier to find the item you want to move in easy-sort mode. You can click an item header to open the item. An "Exit easy-sort mode" button appears at the bottom of the inputfield. Configuration
      In the field settings for Repeater and Repeater Matrix fields you can define a minimum width in pixels for items in easy-sort mode. While in easy-sort mode the items will be sized to neatly fill the available width on any screen size but will never be narrower than the width you set here.
      In the field settings for Repeater Matrix you can define a custom header colour for each matrix type using an HTML "color" type input. The default colour for this type of input is black, so when black is selected in the input it means that no custom colour will be applied to the header.
      Exclusions
      The easy-sort mode is only possible on Repeater/Matrix fields that do not use the "item depth" option.
       
      https://github.com/Toutouwai/RepeaterEasySort
      https://processwire.com/modules/repeater-easy-sort/
×
×
  • Create New...