BoltTranslate / labels

Bolt Labels extension - Translatable labels for Bolt
https://bolt.cm/
18 stars 12 forks source link

Edit labels broken #13

Closed rompcik closed 7 years ago

rompcik commented 8 years ago

If trying to edit labels I get a blank screen with two save buttons... No labels at all, but funny buzz-data in JS. See (beautified) HTML-output:

<div id="navpage-content" class="container-fluid">
    <div class="row">
        <div class="col-xs-12">
            <h1 class="page-header">
                <strong>Edit labels</strong>
            </h1>
        </div>
    </div>

    <form action="/~irata/hotel/bolt/labels/save" method="POST" enctype="multipart/form-data">

        <button class="btn btn-primary" disabled="disabled" id="save-button" type="submit">
            <i class='fa fa-save'></i> Save
        </button>

        <div id="hot-grid" style='margin: 12px 0;'></div>

        <input type="hidden" name="columns" value="[&quot;Label&quot;,&quot;EN&quot;,&quot;DE&quot;]">
        <input type="hidden" name="labels" id="gridfield-labels" value="">

        <button class="btn btn-primary" disabled="disabled" id="save-button-bottom" type="submit">
            <i class='fa fa-save'></i> Save
        </button>

    </form>

    <script>
    jQuery(document).ready(function($) {

      var data = [["badger","badger","Dachs "],["bear","bear","B\u00e4r "],["beaver","beaver","Biber "],["buffalo","buffalo","B\u00fcffel "],["cat","cat","Katze "],["chamois","chamois","Gams , Gemse "],["cow","cow","Rind , Kuh "],["deer (red)","deer (red)","Hirsch "],["dog","dog","Hund "],["donkey","donkey","Esel "],["elephant","elephant","Elefant "],["ermine","ermine","Hermelin "],["ferret","ferret","Frettchen"],["fox","fox","Fuchs "],["goat","goat","Ziege "],["guinea pig","guinea pig","Meerschweinchen "],["hamster","hamster","Hamster "],["hare","hare","Hase "],["hedgehog","hedgehog","Needles "],["horse","horse","Pferd "],["ibex","ibex","Steinbock "],["lynx","lynx","Luchs "],["marmot","marmot","Murmeltier "],["marten","marten","Marder "],["mole","mole","Maulwurf "],["mouse","mouse","Maus"],["otter","otter","Otter "],["pig","pig","Schwein "],["rabbit","rabbit","Kaninchen "],["rat","rat","Ratte "],["sheep","sheep","Schaf "],["shrew","shrew","Spitzmaus "],["squirrel","squirrel","H\u00f6rnchen "],["vole","vole","Schermaus "],["weasel","weasel","Wiesel "],["wild boar","wild boar","Wildschwein "],["wildcat","wildcat","Wildkatze "],["wolf","wolf","Wolf "]];

      var container = document.getElementById('hot-grid');
      var hot = new Handsontable(container,
        {
            autoColumnSize: true,
            minSpareRows: 1,
            width: '100%',
            minCols: 3,
            data: data,
            colHeaders: [ 'Label', 'EN', 'DE' ],
            columnSorting: true,
            sortIndicator: true,
            rowHeaders: false,
            manualRowMove: true,
            contextMenu: true,
            manualColumnResize: true,
            afterRender: updateData,
            afterColumnSort: updateData,
            afterRowMove: updateData
        });
        function updateData(changes, source) {
            if(hot){
                var data = this.getData(0, 0, hot.countRows() - 1, hot.countCols() - 1); // Because #989
                data = data.filter(function(row) {
                    return !_.isEmpty(_.without(row, null));
                });
                jQuery('#gridfield-labels').val(JSON.stringify(data));
                $('#save-button, #save-button-bottom').removeAttr('disabled');
            }
        }

    });
    </script>
</div>
phpetra commented 8 years ago

I had the same issue, you probably have to copy the assets folder (with the js and css files) from wherever they were installed to the /extensions/vendor/bolt/labels or /public/extensions/vendor/bolt/labels folder (depends on your setup)

See https://github.com/bolt/labels/issues/9

rompcik commented 8 years ago

They're at extensions/vendor/bolt/labels already. But i cannot find the link and script includes in HTML output. Seems they are not added. Bolt Version is 2.2.13, not 2.3-dev.

phpetra commented 8 years ago

Have you got the latest version of the extension? The one where you at least have this line in the render method of the Extension.php file? Otherwise, try adding it.

madc commented 8 years ago

This also happens, if your bolt installation is set up in a sub directory. I have a internal domain, that i use to develop (clients.dev). Projects have the url http://clients.dev/<clientname>. Now, the assets get loaded from http://clients.dev/extensions/vendor/bolt/labels/web/underscore-min.js. You can see, that the clientname/sub directory is missing. Should also be the issue in #26..

bobdenotter commented 7 years ago

Fixed in #31