Skip to content

Update main.js - #408

Open
logvik wants to merge 1 commit into
Meteor-Community-Packages:masterfrom
logvik:master
Open

Update main.js#408
logvik wants to merge 1 commit into
Meteor-Community-Packages:masterfrom
logvik:master

Conversation

@logvik

@logvik logvik commented Dec 23, 2017

Copy link
Copy Markdown

Allow a reinitializing. For example, if we change an app language.
Below you can see a simple way to make i18n for a tabular table. Just change Session.set("currentLanguage", "lang"), where lang is a language of the user and the tabular table will be reinitialized automatically.

<template name="yourtemplatewithtabular">
  {{> tabular table=TabularTables.yourTable id="tabularYourTable" class="ui striped table"}}
</template>
Template.yourtemplatewithtabular.onCreated(function() {
  Tracker.autorun(function() {
    $.extend(true, $.fn.dataTable.defaults, {
      language: {
        "decimal":        "",
        "emptyTable":     TAPi18n.__("No data available in table"),
        "info":           TAPi18n.__("Showing _START_ to _END_ of _TOTAL_ entries"),
        "infoEmpty":      TAPi18n.__("Showing 0 to 0 of 0 entries"),
        "infoFiltered":   TAPi18n.__("(filtered from _MAX_ total entries)"),
        "infoPostFix":    "",
        "thousands":      ",",
        "lengthMenu":     TAPi18n.__("Show _MENU_ entries"),
        "loadingRecords": TAPi18n.__("Loading"),
        "processing":     TAPi18n.__("Processing"),
        "search":         TAPi18n.__("Search"),
        "zeroRecords":    TAPi18n.__("No matching records found"),
        "paginate": {
          "first":      TAPi18n.__("First"),
          "last":       TAPi18n.__("Last"),
          "next":       TAPi18n.__("Next"),
          "previous":   TAPi18n.__("Previous")
        },
        "aria": {
          "sortAscending":  TAPi18n.__("activate to sort column ascending"),
          "sortDescending": TAPi18n.__("activate to sort column descending")
        }
      }
    });
    Session.set('Tabular.reinit', Session.get("currentLanguage"));
  });
  dataTablesSemanticUI(window, $);
});

Allow a reinitializing. For example, if we change an app language
@logvik

logvik commented Dec 23, 2017

Copy link
Copy Markdown
Author

related with #94, #85

@guncebektas

Copy link
Copy Markdown
Member

I think this PR should not be approved as it's very specific to an app feature. the package is only using session in https://github.com/Meteor-Community-Packages/meteor-tabular/blob/e9d15a7b758b67bb3930080c4442db9b927393cf/client/main.js and we should convert it to reactiveVar. what do you think?

@jankapunkt

Copy link
Copy Markdown
Member

I think, since the PR is 6 years old we should edit it until it fits the modern requirements.
From that point I'm with you @guncebektas to use reactive var and make it independent from specific use cases.

@guncebektas

Copy link
Copy Markdown
Member

it will be hard to merge #448 but after it is completed I can work to remove the session. It might be good starting point for me.

@jankapunkt

Copy link
Copy Markdown
Member

If you have any concerns regarding #448 please comment there so we can make this the best possible solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants