[GeoNetwork-devel] Templates for Angular directives in GeoNetwork 3

Hi

I’m working in a custom UI for a project, with quite heavy customisations to the UI. One of the issues I’m getting is that the templateUrl of the directives are hardcoded, that means to change the templates in the GN code instead of doing that in the view.

Not an expert in Angular, so maybe there’s a way to override these templates?

Discussing with a colleague in my company, he indicated that a solution could be to replace templateUrl with this:

templateUrl: function ($element, $attrs) {
return $attrs.templateUrl || ‘some/path/default.html’
},

I tried with the gnMapField directive and works fine:

.directive('gnMapField', [
  'gnMap',
  function(gnMap) {
    return {
      restrict: 'A',
      scope: true,
      templateUrl: function ($element, $attrs) {
        return $attrs.templateUrl || '../../catalog/components/search/map/' +
        'partials/mapfield.html'
      },
<div class="floating-map" data-gn-map-field="searchObj.searchMap"
     data-template-url="../../catalog/views/sdi/directives/partials/mapfield.html"

2 questions:

  1. Is there any other simple method to accomplish this?

  2. If not, sounds fine to replace the templateUrl in the directives as described previously? I can manage at least for the directives I need to update for this project.

And maybe should be something to consider also for future developments to follow this pattern for directives?

Regards,
Jose García

···

Vriendelijke groeten / Kind regards,

Jose García


Veenderweg 13
6721 WD Bennekom
The Netherlands
T: +31 (0)318 416664

Please consider the environment before printing this email.

Hello,

The template url could be a variable, could be an angular.value, or could be a function, as you did.
All ways are good, the value is maybe less intrusive.

If you change the code to make the template url configurable, commit it in GN for you not to diverge too much from trunk.

Cheers

···

On Tue, Apr 12, 2016 at 4:49 PM, Jose Garcia <jose.garcia@anonymised.com…> wrote:

Hi

I’m working in a custom UI for a project, with quite heavy customisations to the UI. One of the issues I’m getting is that the templateUrl of the directives are hardcoded, that means to change the templates in the GN code instead of doing that in the view.

Not an expert in Angular, so maybe there’s a way to override these templates?

Discussing with a colleague in my company, he indicated that a solution could be to replace templateUrl with this:

templateUrl: function ($element, $attrs) {
return $attrs.templateUrl || ‘some/path/default.html’
},

I tried with the gnMapField directive and works fine:

.directive('gnMapField', [
  'gnMap',
  function(gnMap) {
    return {
      restrict: 'A',
      scope: true,
      templateUrl: function ($element, $attrs) {
        return $attrs.templateUrl || '../../catalog/components/search/map/' +
        'partials/mapfield.html'
      },
<div class="floating-map" data-gn-map-field="searchObj.searchMap"
     data-template-url="../../catalog/views/sdi/directives/partials/mapfield.html"

2 questions:

  1. Is there any other simple method to accomplish this?

  2. If not, sounds fine to replace the templateUrl in the directives as described previously? I can manage at least for the directives I need to update for this project.

And maybe should be something to consider also for future developments to follow this pattern for directives?

Regards,
Jose García

Vriendelijke groeten / Kind regards,

Jose García


Veenderweg 13
6721 WD Bennekom
The Netherlands
T: +31 (0)318 416664

Please consider the environment before printing this email.


Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z


GeoNetwork-devel mailing list
GeoNetwork-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geonetwork-devel
GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork

camptocamp
INNOVATIVE SOLUTIONS
BY OPEN SOURCE EXPERTS

Florent Gravin
0479444492

Hi Florent

Thanks for the feedback, I need to check about the changes to use instead the value option and will commit to trunk.

Regards,
Jose García

···

On Tue, Apr 12, 2016 at 4:55 PM, Florent Gravin <florent.gravin@anonymised.com> wrote:

Hello,

The template url could be a variable, could be an angular.value, or could be a function, as you did.
All ways are good, the value is maybe less intrusive.

If you change the code to make the template url configurable, commit it in GN for you not to diverge too much from trunk.

Cheers

On Tue, Apr 12, 2016 at 4:49 PM, Jose Garcia <jose.garcia@anonymised.com> wrote:

Hi

I’m working in a custom UI for a project, with quite heavy customisations to the UI. One of the issues I’m getting is that the templateUrl of the directives are hardcoded, that means to change the templates in the GN code instead of doing that in the view.

Not an expert in Angular, so maybe there’s a way to override these templates?

Discussing with a colleague in my company, he indicated that a solution could be to replace templateUrl with this:

templateUrl: function ($element, $attrs) {
return $attrs.templateUrl || ‘some/path/default.html’
},

I tried with the gnMapField directive and works fine:

.directive('gnMapField', [
  'gnMap',
  function(gnMap) {
    return {
      restrict: 'A',
      scope: true,
      templateUrl: function ($element, $attrs) {
        return $attrs.templateUrl || '../../catalog/components/search/map/' +
        'partials/mapfield.html'
      },
<div class="floating-map" data-gn-map-field="searchObj.searchMap"
     data-template-url="../../catalog/views/sdi/directives/partials/mapfield.html"

2 questions:

  1. Is there any other simple method to accomplish this?

  2. If not, sounds fine to replace the templateUrl in the directives as described previously? I can manage at least for the directives I need to update for this project.

And maybe should be something to consider also for future developments to follow this pattern for directives?

Regards,
Jose García

Vriendelijke groeten / Kind regards,

Jose García


Veenderweg 13
6721 WD Bennekom
The Netherlands
T: +31 (0)318 416664

Please consider the environment before printing this email.


Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z


GeoNetwork-devel mailing list
GeoNetwork-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geonetwork-devel
GeoNetwork OpenSource is maintained at http://sourceforge.net/projects/geonetwork

camptocamp
INNOVATIVE SOLUTIONS
BY OPEN SOURCE EXPERTS

Florent Gravin
0479444492

Vriendelijke groeten / Kind regards,

Jose García


Veenderweg 13
6721 WD Bennekom
The Netherlands
T: +31 (0)318 416664

Please consider the environment before printing this email.