meanjs / generator-meanjs

MEAN.JS Official Yeoman Generator
http://meanjs.org/
473 stars 178 forks source link

CRUD modules #250 #252

Closed muniz95 closed 5 years ago

muniz95 commented 8 years ago

Correction of this issue: https://github.com/meanjs/generator-meanjs/issues/250

mleanos commented 7 years ago

@muniz95 The correct name of the service in the master branch of MEANJS is "menuService".

Shouldn't the client.config template reference the correct name as it appears on master? I'm asking since I haven't spent much time on the generator project, so I don't know if these templates should be referencing master or previous releases.

@codydaig @ilanbiala Can you provide insight here?

codydaig commented 7 years ago

That's where this generator lacks is versioning. In theory it should be up to date with the latest master version, however, that would break people not running the latest code base.

muniz95 commented 7 years ago

Well, I renamed the reference from "menuService" to "Menus" on the .client.config generated file and everything worked fine again. Because of this fact I submitted this pull request. I can close it and try to apply the best fix for such issue if you prefer.

mleanos commented 7 years ago

IIRC, there was a bit of discussion on this very topic a while back. I can't recall if the idea of having a template for each release, and one for master, was discussed.

I wouldn't think this strategy would be too difficult to maintain. Most of the work would be to coordinate changes in the master branch. Once we release a new version of MEANJS, then we would create a new template for that release. Would this work? This shortcoming of the generator seems to be unique of the stand-alone generators (i.e. angular-*, and express-*).

codydaig commented 7 years ago

@mleanos Correct. However, there's also the issue of is breaking on master. So if you generated on master before this change was made then it would break your code next time you used the generator.

rifrayugo commented 7 years ago

@muniz95 i have changed menuServices with Menus. But i encounter new problem after i choose that menu. I see error 404 view doesn't load in browser console. Do you know to solve that problem?

LuisT commented 7 years ago

Have you the 404 error yet? I had the same problem and so far I can't achieved to solve it. Thanks in advance.

theednaffattack commented 7 years ago

@LuisT I fixed this a different way. I noticed that the articles example module had very different code inside the client config file. It's more than just changing 'menuService' to 'Menus'. I've included the articles config with the non-working and working versions of my new 'skills' module below.

articles.client.config.js:

'use strict';

// Configuring the Articles module
angular.module('articles').run(['Menus',
  function (Menus) {
    // Add the articles dropdown item
    Menus.addMenuItem('topbar', {
      title: 'Articles',
      state: 'articles',
      type: 'dropdown',
      roles: ['*']
    });

    // Add the dropdown list item
    Menus.addSubMenuItem('topbar', 'articles', {
      title: 'List Articles',
      state: 'articles.list'
    });

    // Add the dropdown create item
    Menus.addSubMenuItem('topbar', 'articles', {
      title: 'Create Articles',
      state: 'articles.create',
      roles: ['user']
    });
  }
]);

GENERATED skills.client.config.js:

(function () {
  'use strict';

  angular
    .module('skills')
    .run(menuConfig);

  menuConfig.$inject = ['menuService'];

  function menuConfig(menuService) {
    // Set top bar menu items
    menuService.addMenuItem('topbar', {
      title: 'Skills',
      state: 'skills',
      type: 'dropdown',
      roles: ['*']
    });

    // Add the dropdown list item
    menuService.addSubMenuItem('topbar', 'skills', {
      title: 'List Skills',
      state: 'skills.list'
    });

    // Add the dropdown create item
    menuService.addSubMenuItem('topbar', 'skills', {
      title: 'Create Skill',
      state: 'skills.create',
      roles: ['user']
    });
  }
}());

FIXED skills.client.config.js

'use strict';

// Configuring the Articles module
angular.module('skills').run(['Menus',
  function (Menus) {
    // Add the articles dropdown item
    Menus.addMenuItem('topbar', {
      title: 'Skills',
      state: 'skills',
      type: 'dropdown',
      roles: ['*']
    });

    // Add the dropdown list item
    Menus.addSubMenuItem('topbar', 'skills', {
      title: 'List Skills',
      state: 'skills.list'
    });

    // Add the dropdown create item
    Menus.addSubMenuItem('topbar', 'skills', {
      title: 'Create Skill',
      state: 'skills.create',
      roles: ['user']
    });
  }
]);