decidim-navbar_links 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/LICENSE-AGPLv3.txt +661 -0
 - data/README.md +39 -0
 - data/Rakefile +27 -0
 - data/app/assets/config/decidim_navbar_links_manifest.js +0 -0
 - data/app/assets/images/decidim/navbar_links/icon.svg +1 -0
 - data/app/commands/decidim/navbar_links/admin/create_navbar_link.rb +44 -0
 - data/app/commands/decidim/navbar_links/admin/update_navbar_link.rb +49 -0
 - data/app/controllers/decidim/navbar_links/admin/application_controller.rb +18 -0
 - data/app/controllers/decidim/navbar_links/admin/navbar_links_controller.rb +76 -0
 - data/app/controllers/decidim/navbar_links/application_controller.rb +13 -0
 - data/app/forms/decidim/navbar_links/admin/navbar_link_form.rb +23 -0
 - data/app/forms/decidim/navbar_links/application_controller.rb +13 -0
 - data/app/helpers/decidim/navbar_links/application_helper.rb +10 -0
 - data/app/models/decidim/navbar_links/application_record.rb +10 -0
 - data/app/models/decidim/navbar_links/navbar_link.rb +18 -0
 - data/app/permissions/decidim/navbar_links/admin/permissions.rb +21 -0
 - data/app/views/decidim/navbar_links/admin/navbar_links/_form.html.erb +16 -0
 - data/app/views/decidim/navbar_links/admin/navbar_links/edit.html.erb +13 -0
 - data/app/views/decidim/navbar_links/admin/navbar_links/index.html.erb +48 -0
 - data/app/views/decidim/navbar_links/admin/navbar_links/new.html.erb +13 -0
 - data/app/views/layouts/decidim/admin/settings.html.erb +40 -0
 - data/config/i18n-tasks.yml +10 -0
 - data/config/locales/en.yml +64 -0
 - data/lib/decidim/navbar_links/admin.rb +10 -0
 - data/lib/decidim/navbar_links/admin_engine.rb +28 -0
 - data/lib/decidim/navbar_links/engine.rb +25 -0
 - data/lib/decidim/navbar_links/test/factories.rb +13 -0
 - data/lib/decidim/navbar_links/version.rb +10 -0
 - data/lib/decidim/navbar_links.rb +12 -0
 - metadata +86 -0
 
    
        data/README.md
    ADDED
    
    | 
         @@ -0,0 +1,39 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Decidim::NavbarLinks
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            [](https://circleci.com/gh/OpenSourcePolitics/decidim-module-navbar_links)
         
     | 
| 
      
 4 
     | 
    
         
            +
            [](https://codeclimate.com/github/OpenSourcePolitics/decidim-module-navbar_links/maintainability)
         
     | 
| 
      
 5 
     | 
    
         
            +
            [](https://codeclimate.com/github/OpenSourcePolitics/decidim-module-navbar_links/test_coverage)
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            ## Usage
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            NavbarLinks adds a custom link to your decidim menu.
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            Admin view:
         
     | 
| 
      
 12 
     | 
    
         
            +
            
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            Homepage view:
         
     | 
| 
      
 15 
     | 
    
         
            +
            
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            ## Installation
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            Add this line to your application's Gemfile:
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 22 
     | 
    
         
            +
            gem 'decidim-navbar_links', git: "https://github.com/OpenSourcePolitics/decidim-module-navbar_links"
         
     | 
| 
      
 23 
     | 
    
         
            +
            ```
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            And then execute:
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            ```bash
         
     | 
| 
      
 28 
     | 
    
         
            +
            $ bundle
         
     | 
| 
      
 29 
     | 
    
         
            +
            $ bundle exec rake decidim_navbar_links:install:migrations
         
     | 
| 
      
 30 
     | 
    
         
            +
            $ bundle exec rake db:migrate
         
     | 
| 
      
 31 
     | 
    
         
            +
            ```
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            ## Contributing
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            See [Decidim](https://github.com/decidim/decidim).
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            ## License
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            This engine is distributed under the GNU AFFERO GENERAL PUBLIC LICENSE.
         
     | 
    
        data/Rakefile
    ADDED
    
    | 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "decidim/dev/common_rake"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            def install_module(path)
         
     | 
| 
      
 6 
     | 
    
         
            +
              Dir.chdir(path) do
         
     | 
| 
      
 7 
     | 
    
         
            +
                system("bundle exec rake decidim_navbar_links:install:migrations")
         
     | 
| 
      
 8 
     | 
    
         
            +
                system("bundle exec rake db:migrate")
         
     | 
| 
      
 9 
     | 
    
         
            +
              end
         
     | 
| 
      
 10 
     | 
    
         
            +
            end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            def seed_db(path)
         
     | 
| 
      
 13 
     | 
    
         
            +
              Dir.chdir(path) do
         
     | 
| 
      
 14 
     | 
    
         
            +
                system("bundle exec rake db:seed")
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            desc "Generates a dummy app for testing"
         
     | 
| 
      
 19 
     | 
    
         
            +
            task test_app: "decidim:generate_external_test_app" do
         
     | 
| 
      
 20 
     | 
    
         
            +
              ENV["RAILS_ENV"] = "test"
         
     | 
| 
      
 21 
     | 
    
         
            +
              install_module("spec/decidim_dummy_app")
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            desc "Generates a development app"
         
     | 
| 
      
 25 
     | 
    
         
            +
            task development_app: "decidim:generate_external_development_app" do
         
     | 
| 
      
 26 
     | 
    
         
            +
              install_module("development_app")
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
         
            File without changes
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 35 35"><path d="M17.5 35A17.5 17.5 0 1 1 35 17.5 17.52 17.52 0 0 1 17.5 35zm0-33.06A15.56 15.56 0 1 0 33.06 17.5 15.57 15.57 0 0 0 17.5 1.94zm9.5 13.7H8a1 1 0 0 1 0-1.94h19a1 1 0 0 1 0 1.94zm0 3.68H8a1 1 0 0 1 0-1.94h19a1 1 0 0 1 0 1.94zM22.26 23H8a1 1 0 0 1 0-1.94h14.26a1 1 0 0 1 0 1.94z"/></svg>
         
     | 
| 
         @@ -0,0 +1,44 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Decidim
         
     | 
| 
      
 4 
     | 
    
         
            +
              module NavbarLinks
         
     | 
| 
      
 5 
     | 
    
         
            +
                module Admin
         
     | 
| 
      
 6 
     | 
    
         
            +
                  # A command with all the business logic when creating a static NavbarLink.
         
     | 
| 
      
 7 
     | 
    
         
            +
                  class CreateNavbarLink < Rectify::Command
         
     | 
| 
      
 8 
     | 
    
         
            +
                    # Public: Initializes the command.
         
     | 
| 
      
 9 
     | 
    
         
            +
                    #
         
     | 
| 
      
 10 
     | 
    
         
            +
                    # form - A form object with the params.
         
     | 
| 
      
 11 
     | 
    
         
            +
                    def initialize(form)
         
     | 
| 
      
 12 
     | 
    
         
            +
                      @form = form
         
     | 
| 
      
 13 
     | 
    
         
            +
                    end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                    # Executes the command. Broadcasts these events:
         
     | 
| 
      
 16 
     | 
    
         
            +
                    #
         
     | 
| 
      
 17 
     | 
    
         
            +
                    # - :ok when everything is valid.
         
     | 
| 
      
 18 
     | 
    
         
            +
                    # - :invalid if the form wasn't valid and we couldn't proceed.
         
     | 
| 
      
 19 
     | 
    
         
            +
                    #
         
     | 
| 
      
 20 
     | 
    
         
            +
                    # Returns nothing.
         
     | 
| 
      
 21 
     | 
    
         
            +
                    def call
         
     | 
| 
      
 22 
     | 
    
         
            +
                      return broadcast(:invalid) if form.invalid?
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                      create_navbar_link
         
     | 
| 
      
 25 
     | 
    
         
            +
                      broadcast(:ok)
         
     | 
| 
      
 26 
     | 
    
         
            +
                    end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                    private
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                    attr_reader :form
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                    def create_navbar_link
         
     | 
| 
      
 33 
     | 
    
         
            +
                      Decidim::NavbarLinks::NavbarLink.create!(
         
     | 
| 
      
 34 
     | 
    
         
            +
                        title: form.title,
         
     | 
| 
      
 35 
     | 
    
         
            +
                        link: form.link,
         
     | 
| 
      
 36 
     | 
    
         
            +
                        weight: form.weight,
         
     | 
| 
      
 37 
     | 
    
         
            +
                        target: form.target,
         
     | 
| 
      
 38 
     | 
    
         
            +
                        organization: form.organization
         
     | 
| 
      
 39 
     | 
    
         
            +
                      )
         
     | 
| 
      
 40 
     | 
    
         
            +
                    end
         
     | 
| 
      
 41 
     | 
    
         
            +
                  end
         
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
      
 43 
     | 
    
         
            +
              end
         
     | 
| 
      
 44 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,49 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Decidim
         
     | 
| 
      
 4 
     | 
    
         
            +
              module NavbarLinks
         
     | 
| 
      
 5 
     | 
    
         
            +
                module Admin
         
     | 
| 
      
 6 
     | 
    
         
            +
                  # A command with all the business logic when updating a navbar link.
         
     | 
| 
      
 7 
     | 
    
         
            +
                  class UpdateNavbarLink < Rectify::Command
         
     | 
| 
      
 8 
     | 
    
         
            +
                    # Public: Initializes the command.
         
     | 
| 
      
 9 
     | 
    
         
            +
                    #
         
     | 
| 
      
 10 
     | 
    
         
            +
                    # form - A form object with the params.
         
     | 
| 
      
 11 
     | 
    
         
            +
                    def initialize(form, navbar_link)
         
     | 
| 
      
 12 
     | 
    
         
            +
                      @form = form
         
     | 
| 
      
 13 
     | 
    
         
            +
                      @navbar_link = navbar_link
         
     | 
| 
      
 14 
     | 
    
         
            +
                    end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                    # Executes the command. Broadcasts these events:
         
     | 
| 
      
 17 
     | 
    
         
            +
                    #
         
     | 
| 
      
 18 
     | 
    
         
            +
                    # - :ok when everything is valid.
         
     | 
| 
      
 19 
     | 
    
         
            +
                    # - :invalid if the form wasn't valid and we couldn't proceed.
         
     | 
| 
      
 20 
     | 
    
         
            +
                    #
         
     | 
| 
      
 21 
     | 
    
         
            +
                    # Returns nothing.
         
     | 
| 
      
 22 
     | 
    
         
            +
                    def call
         
     | 
| 
      
 23 
     | 
    
         
            +
                      return broadcast(:invalid) if form.invalid?
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                      update_navbar_link
         
     | 
| 
      
 26 
     | 
    
         
            +
                      broadcast(:ok)
         
     | 
| 
      
 27 
     | 
    
         
            +
                    end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                    private
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                    attr_reader :form
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                    def update_navbar_link
         
     | 
| 
      
 34 
     | 
    
         
            +
                      @navbar_link.update!(attributes)
         
     | 
| 
      
 35 
     | 
    
         
            +
                    end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                    def attributes
         
     | 
| 
      
 38 
     | 
    
         
            +
                      {
         
     | 
| 
      
 39 
     | 
    
         
            +
                        title: form.title,
         
     | 
| 
      
 40 
     | 
    
         
            +
                        link: form.link,
         
     | 
| 
      
 41 
     | 
    
         
            +
                        weight: form.weight,
         
     | 
| 
      
 42 
     | 
    
         
            +
                        target: form.target,
         
     | 
| 
      
 43 
     | 
    
         
            +
                        organization: form.organization
         
     | 
| 
      
 44 
     | 
    
         
            +
                      }
         
     | 
| 
      
 45 
     | 
    
         
            +
                    end
         
     | 
| 
      
 46 
     | 
    
         
            +
                  end
         
     | 
| 
      
 47 
     | 
    
         
            +
                end
         
     | 
| 
      
 48 
     | 
    
         
            +
              end
         
     | 
| 
      
 49 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Decidim
         
     | 
| 
      
 4 
     | 
    
         
            +
              module NavbarLinks
         
     | 
| 
      
 5 
     | 
    
         
            +
                module Admin
         
     | 
| 
      
 6 
     | 
    
         
            +
                  # This controller is the abstract class from which all other controllers of
         
     | 
| 
      
 7 
     | 
    
         
            +
                  # this engine inherit.
         
     | 
| 
      
 8 
     | 
    
         
            +
                  #
         
     | 
| 
      
 9 
     | 
    
         
            +
                  # Note that it inherits from `decidim::admin::Components::BaseController`, which
         
     | 
| 
      
 10 
     | 
    
         
            +
                  # override its layout and provide all kinds of useful methods.
         
     | 
| 
      
 11 
     | 
    
         
            +
                  class ApplicationController < Decidim::Admin::ApplicationController
         
     | 
| 
      
 12 
     | 
    
         
            +
                    def permission_class_chain
         
     | 
| 
      
 13 
     | 
    
         
            +
                      [Decidim::NavbarLinks::Admin::Permissions] + super
         
     | 
| 
      
 14 
     | 
    
         
            +
                    end
         
     | 
| 
      
 15 
     | 
    
         
            +
                  end
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,76 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Decidim
         
     | 
| 
      
 4 
     | 
    
         
            +
              module NavbarLinks
         
     | 
| 
      
 5 
     | 
    
         
            +
                module Admin
         
     | 
| 
      
 6 
     | 
    
         
            +
                  class NavbarLinksController < NavbarLinks::Admin::ApplicationController
         
     | 
| 
      
 7 
     | 
    
         
            +
                    layout "decidim/admin/settings"
         
     | 
| 
      
 8 
     | 
    
         
            +
                    helper_method :navbar_link
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                    def index
         
     | 
| 
      
 11 
     | 
    
         
            +
                      enforce_permission_to :index, :navbar_link
         
     | 
| 
      
 12 
     | 
    
         
            +
                      @navbar_links = NavbarLink.organization(current_organization)
         
     | 
| 
      
 13 
     | 
    
         
            +
                    end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                    def new
         
     | 
| 
      
 16 
     | 
    
         
            +
                      enforce_permission_to :new, :navbar_link
         
     | 
| 
      
 17 
     | 
    
         
            +
                      @form = form(Decidim::NavbarLinks::Admin::NavbarLinkForm).instance
         
     | 
| 
      
 18 
     | 
    
         
            +
                    end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                    def create
         
     | 
| 
      
 21 
     | 
    
         
            +
                      enforce_permission_to :new, :navbar_link
         
     | 
| 
      
 22 
     | 
    
         
            +
                      @form = form(Decidim::NavbarLinks::Admin::NavbarLinkForm).from_params(params)
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                      Decidim::NavbarLinks::Admin::CreateNavbarLink.call(@form) do
         
     | 
| 
      
 25 
     | 
    
         
            +
                        on(:ok) do
         
     | 
| 
      
 26 
     | 
    
         
            +
                          flash[:notice] = I18n.t("navbar_links.create.success", scope: "decidim.admin")
         
     | 
| 
      
 27 
     | 
    
         
            +
                          redirect_to navbar_links_path
         
     | 
| 
      
 28 
     | 
    
         
            +
                        end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                        on(:invalid) do
         
     | 
| 
      
 31 
     | 
    
         
            +
                          flash.now[:alert] = I18n.t("navbar_links.create.error", scope: "decidim.admin")
         
     | 
| 
      
 32 
     | 
    
         
            +
                          render :new
         
     | 
| 
      
 33 
     | 
    
         
            +
                        end
         
     | 
| 
      
 34 
     | 
    
         
            +
                      end
         
     | 
| 
      
 35 
     | 
    
         
            +
                    end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                    def edit
         
     | 
| 
      
 38 
     | 
    
         
            +
                      enforce_permission_to :update, :navbar_link, navbar_link: navbar_link
         
     | 
| 
      
 39 
     | 
    
         
            +
                      @form = form(Decidim::NavbarLinks::Admin::NavbarLinkForm).from_model(navbar_link)
         
     | 
| 
      
 40 
     | 
    
         
            +
                    end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                    def update
         
     | 
| 
      
 43 
     | 
    
         
            +
                      enforce_permission_to :update, :navbar_link, navbar_link: navbar_link
         
     | 
| 
      
 44 
     | 
    
         
            +
                      @form = form(Decidim::NavbarLinks::Admin::NavbarLinkForm).from_params(params)
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                      Decidim::NavbarLinks::Admin::UpdateNavbarLink.call(@form, navbar_link) do
         
     | 
| 
      
 47 
     | 
    
         
            +
                        on(:ok) do
         
     | 
| 
      
 48 
     | 
    
         
            +
                          flash[:notice] = I18n.t("navbar_links.update.success", scope: "decidim.admin")
         
     | 
| 
      
 49 
     | 
    
         
            +
                          redirect_to navbar_links_path
         
     | 
| 
      
 50 
     | 
    
         
            +
                        end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                        on(:invalid) do
         
     | 
| 
      
 53 
     | 
    
         
            +
                          flash.now[:alert] = I18n.t("navbar_links.update.error", scope: "decidim.admin")
         
     | 
| 
      
 54 
     | 
    
         
            +
                          render :edit
         
     | 
| 
      
 55 
     | 
    
         
            +
                        end
         
     | 
| 
      
 56 
     | 
    
         
            +
                      end
         
     | 
| 
      
 57 
     | 
    
         
            +
                    end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                    def destroy
         
     | 
| 
      
 60 
     | 
    
         
            +
                      enforce_permission_to :destroy, :navbar_link
         
     | 
| 
      
 61 
     | 
    
         
            +
                      navbar_link.destroy!
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                      flash[:notice] = I18n.t("navbar_links.destroy.success", scope: "decidim.admin")
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                      redirect_to navbar_links_path
         
     | 
| 
      
 66 
     | 
    
         
            +
                    end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                    private
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                    def navbar_link
         
     | 
| 
      
 71 
     | 
    
         
            +
                      @navbar_link = Decidim::NavbarLinks::NavbarLink.find(params[:id])
         
     | 
| 
      
 72 
     | 
    
         
            +
                    end
         
     | 
| 
      
 73 
     | 
    
         
            +
                  end
         
     | 
| 
      
 74 
     | 
    
         
            +
                end
         
     | 
| 
      
 75 
     | 
    
         
            +
              end
         
     | 
| 
      
 76 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Decidim
         
     | 
| 
      
 4 
     | 
    
         
            +
              module NavbarLinks
         
     | 
| 
      
 5 
     | 
    
         
            +
                # This controller is the abstract class from which all other controllers of
         
     | 
| 
      
 6 
     | 
    
         
            +
                # this engine inherit.
         
     | 
| 
      
 7 
     | 
    
         
            +
                #
         
     | 
| 
      
 8 
     | 
    
         
            +
                # Note that it inherits from `Decidim::Components::BaseController`, which
         
     | 
| 
      
 9 
     | 
    
         
            +
                # override its layout and provide all kinds of useful methods.
         
     | 
| 
      
 10 
     | 
    
         
            +
                class ApplicationController < Decidim::Components::BaseController
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Decidim
         
     | 
| 
      
 4 
     | 
    
         
            +
              module NavbarLinks
         
     | 
| 
      
 5 
     | 
    
         
            +
                module Admin
         
     | 
| 
      
 6 
     | 
    
         
            +
                  # A form object to create or update scopes.
         
     | 
| 
      
 7 
     | 
    
         
            +
                  class NavbarLinkForm < Form
         
     | 
| 
      
 8 
     | 
    
         
            +
                    include TranslatableAttributes
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                    translatable_attribute :title, String
         
     | 
| 
      
 11 
     | 
    
         
            +
                    attribute :link, String
         
     | 
| 
      
 12 
     | 
    
         
            +
                    attribute :weight, Integer
         
     | 
| 
      
 13 
     | 
    
         
            +
                    attribute :target, String
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                    validates :link, format: { with: URI.regexp(%w(http https)) }, presence: true
         
     | 
| 
      
 16 
     | 
    
         
            +
                    validates :title, translatable_presence: true
         
     | 
| 
      
 17 
     | 
    
         
            +
                    validates :weight, presence: true
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                    alias organization current_organization
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Decidim
         
     | 
| 
      
 4 
     | 
    
         
            +
              module NavbarLinks
         
     | 
| 
      
 5 
     | 
    
         
            +
                # This controller is the abstract class from which all other controllers of
         
     | 
| 
      
 6 
     | 
    
         
            +
                # this engine inherit.
         
     | 
| 
      
 7 
     | 
    
         
            +
                #
         
     | 
| 
      
 8 
     | 
    
         
            +
                # Note that it inherits from `Decidim::Components::BaseController`, which
         
     | 
| 
      
 9 
     | 
    
         
            +
                # override its layout and provide all kinds of useful methods.
         
     | 
| 
      
 10 
     | 
    
         
            +
                class ApplicationController < Decidim::Components::BaseController
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Decidim
         
     | 
| 
      
 4 
     | 
    
         
            +
              module NavbarLinks
         
     | 
| 
      
 5 
     | 
    
         
            +
                class NavbarLink < ApplicationRecord
         
     | 
| 
      
 6 
     | 
    
         
            +
                  belongs_to :organization, foreign_key: "decidim_organization_id", class_name: "Decidim::Organization"
         
     | 
| 
      
 7 
     | 
    
         
            +
                  scope :organization, ->(organization) { where(organization: organization) }
         
     | 
| 
      
 8 
     | 
    
         
            +
                  before_save :validate_link_regex
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  def validate_link_regex
         
     | 
| 
      
 11 
     | 
    
         
            +
                    link = URI.parse(self.link)
         
     | 
| 
      
 12 
     | 
    
         
            +
                    link&.host
         
     | 
| 
      
 13 
     | 
    
         
            +
                  rescue URI::InvalidURIError
         
     | 
| 
      
 14 
     | 
    
         
            +
                    errors.add(:link)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  end
         
     | 
| 
      
 16 
     | 
    
         
            +
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
              end
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Decidim
         
     | 
| 
      
 4 
     | 
    
         
            +
              module NavbarLinks
         
     | 
| 
      
 5 
     | 
    
         
            +
                module Admin
         
     | 
| 
      
 6 
     | 
    
         
            +
                  class Permissions < Decidim::DefaultPermissions
         
     | 
| 
      
 7 
     | 
    
         
            +
                    def permissions
         
     | 
| 
      
 8 
     | 
    
         
            +
                      if permission_action.subject == :navbar_link
         
     | 
| 
      
 9 
     | 
    
         
            +
                        if permission_action.scope == :admin && user&.admin?
         
     | 
| 
      
 10 
     | 
    
         
            +
                          allow!
         
     | 
| 
      
 11 
     | 
    
         
            +
                        else
         
     | 
| 
      
 12 
     | 
    
         
            +
                          disallow!
         
     | 
| 
      
 13 
     | 
    
         
            +
                        end
         
     | 
| 
      
 14 
     | 
    
         
            +
                      end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                      permission_action
         
     | 
| 
      
 17 
     | 
    
         
            +
                    end
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,16 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <div class="row column">
         
     | 
| 
      
 2 
     | 
    
         
            +
              <%= form.translated :text_field, :title, label: t(".title") %>
         
     | 
| 
      
 3 
     | 
    
         
            +
            </div>
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            <div class="row">
         
     | 
| 
      
 6 
     | 
    
         
            +
              <div class="columns xlarge-6">
         
     | 
| 
      
 7 
     | 
    
         
            +
                <%= form.text_field :link, placeholder: "http://", label: t(".link") %>
         
     | 
| 
      
 8 
     | 
    
         
            +
              </div>
         
     | 
| 
      
 9 
     | 
    
         
            +
              <div class="columns xlarge-6">
         
     | 
| 
      
 10 
     | 
    
         
            +
                <%= form.number_field :weight, label: t(".weight") %>
         
     | 
| 
      
 11 
     | 
    
         
            +
              </div>
         
     | 
| 
      
 12 
     | 
    
         
            +
              <div class="columns xlarge-6">
         
     | 
| 
      
 13 
     | 
    
         
            +
                <%= form.radio_button :target, "blank", label: t(".new_tab") %>
         
     | 
| 
      
 14 
     | 
    
         
            +
                <%= form.radio_button :target, "", label: t(".same_tab") %>
         
     | 
| 
      
 15 
     | 
    
         
            +
              </div>
         
     | 
| 
      
 16 
     | 
    
         
            +
            </div>
         
     | 
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <%= decidim_form_for(@form) do |f| %>
         
     | 
| 
      
 2 
     | 
    
         
            +
              <div class="card">
         
     | 
| 
      
 3 
     | 
    
         
            +
                <div class="card-divider">
         
     | 
| 
      
 4 
     | 
    
         
            +
                  <h2 class="card-title"><%= t ".title" %></h2>
         
     | 
| 
      
 5 
     | 
    
         
            +
                </div>
         
     | 
| 
      
 6 
     | 
    
         
            +
                <div class="card-section">
         
     | 
| 
      
 7 
     | 
    
         
            +
                  <%= render partial: "form", object: f %>
         
     | 
| 
      
 8 
     | 
    
         
            +
                </div>
         
     | 
| 
      
 9 
     | 
    
         
            +
              </div>
         
     | 
| 
      
 10 
     | 
    
         
            +
              <div class="button--double form-general-submit">
         
     | 
| 
      
 11 
     | 
    
         
            +
                <%= f.submit t(".update") %>
         
     | 
| 
      
 12 
     | 
    
         
            +
              </div>
         
     | 
| 
      
 13 
     | 
    
         
            +
            <% end %>
         
     | 
| 
         @@ -0,0 +1,48 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <div class="card" id="navbar_links">
         
     | 
| 
      
 2 
     | 
    
         
            +
              <div class="card-divider">
         
     | 
| 
      
 3 
     | 
    
         
            +
                <h2 class="card-title">
         
     | 
| 
      
 4 
     | 
    
         
            +
                    <%= t "decidim.admin.titles.navbar_links" %> <%= link_to t("actions.add", scope: "decidim.admin"), new_navbar_link_path, class: "button tiny button--title" %>
         
     | 
| 
      
 5 
     | 
    
         
            +
                </h2>
         
     | 
| 
      
 6 
     | 
    
         
            +
              </div>
         
     | 
| 
      
 7 
     | 
    
         
            +
              <div class="card-section">
         
     | 
| 
      
 8 
     | 
    
         
            +
                <% if @navbar_links.any? %>
         
     | 
| 
      
 9 
     | 
    
         
            +
                  <div class="table-scroll">
         
     | 
| 
      
 10 
     | 
    
         
            +
                    <table class="table-list">
         
     | 
| 
      
 11 
     | 
    
         
            +
                    <thead>
         
     | 
| 
      
 12 
     | 
    
         
            +
                      <tr>
         
     | 
| 
      
 13 
     | 
    
         
            +
                        <th><%= t("models.navbar_link.fields.title", scope: "decidim.admin") %></th>
         
     | 
| 
      
 14 
     | 
    
         
            +
                        <th><%= t("models.navbar_link.fields.weight", scope: "decidim.admin") %></th>
         
     | 
| 
      
 15 
     | 
    
         
            +
                        <th><%= t("models.navbar_link.fields.link", scope: "decidim.admin") %></th>
         
     | 
| 
      
 16 
     | 
    
         
            +
                        <th></th>
         
     | 
| 
      
 17 
     | 
    
         
            +
                      </tr>
         
     | 
| 
      
 18 
     | 
    
         
            +
                    </thead>
         
     | 
| 
      
 19 
     | 
    
         
            +
                    <tbody>
         
     | 
| 
      
 20 
     | 
    
         
            +
                      <% @navbar_links.each do |navbar_link| %>
         
     | 
| 
      
 21 
     | 
    
         
            +
                        <tr id="<%= "navbar_link_#{navbar_link.id}" %>">
         
     | 
| 
      
 22 
     | 
    
         
            +
                          <td>
         
     | 
| 
      
 23 
     | 
    
         
            +
                            <%= translated_attribute(navbar_link.title) %>
         
     | 
| 
      
 24 
     | 
    
         
            +
                          </td>
         
     | 
| 
      
 25 
     | 
    
         
            +
                          <td>
         
     | 
| 
      
 26 
     | 
    
         
            +
                            <%= navbar_link.weight %>
         
     | 
| 
      
 27 
     | 
    
         
            +
                          </td>
         
     | 
| 
      
 28 
     | 
    
         
            +
                          <td>
         
     | 
| 
      
 29 
     | 
    
         
            +
                            <%= link_to navbar_link.link, navbar_link.link, target: :blank %>
         
     | 
| 
      
 30 
     | 
    
         
            +
                          </td>
         
     | 
| 
      
 31 
     | 
    
         
            +
                          <td class="table-list__actions">
         
     | 
| 
      
 32 
     | 
    
         
            +
                            <% if allowed_to? :update, :navbar_link %>
         
     | 
| 
      
 33 
     | 
    
         
            +
                              <%= icon_link_to "pencil", ["edit", navbar_link], t("actions.edit", scope: "decidim.admin"), class: "action-icon--edit", method: :get, data: {} %>
         
     | 
| 
      
 34 
     | 
    
         
            +
                            <% end %>
         
     | 
| 
      
 35 
     | 
    
         
            +
                            <% if allowed_to? :destroy, :navbar_link %>
         
     | 
| 
      
 36 
     | 
    
         
            +
                              <%= icon_link_to "circle-x", navbar_link, t("actions.destroy", scope: "decidim.admin"), class: "action-icon--remove", method: :delete, data: { confirm: t("actions.confirm_destroy", scope: "decidim.admin") } %>
         
     | 
| 
      
 37 
     | 
    
         
            +
                            <% end %>
         
     | 
| 
      
 38 
     | 
    
         
            +
                          </td>
         
     | 
| 
      
 39 
     | 
    
         
            +
                        </tr>
         
     | 
| 
      
 40 
     | 
    
         
            +
                      <% end %>
         
     | 
| 
      
 41 
     | 
    
         
            +
                    </tbody>
         
     | 
| 
      
 42 
     | 
    
         
            +
                    </table>
         
     | 
| 
      
 43 
     | 
    
         
            +
                  </div>
         
     | 
| 
      
 44 
     | 
    
         
            +
                <% else %>
         
     | 
| 
      
 45 
     | 
    
         
            +
                  <p><%= t("decidim.admin.navbar_links.no_links") %></p>
         
     | 
| 
      
 46 
     | 
    
         
            +
                <% end %>
         
     | 
| 
      
 47 
     | 
    
         
            +
              </div>
         
     | 
| 
      
 48 
     | 
    
         
            +
            </div>
         
     | 
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <%= decidim_form_for(@form, url: navbar_links_path) do |f| %>
         
     | 
| 
      
 2 
     | 
    
         
            +
              <div class="card">
         
     | 
| 
      
 3 
     | 
    
         
            +
                <div class="card-divider">
         
     | 
| 
      
 4 
     | 
    
         
            +
                  <h2 class="card-title"><%= t ".title" %></h2>
         
     | 
| 
      
 5 
     | 
    
         
            +
                </div>
         
     | 
| 
      
 6 
     | 
    
         
            +
                <div class="card-section">
         
     | 
| 
      
 7 
     | 
    
         
            +
                  <%= render partial: "form", object: f %>
         
     | 
| 
      
 8 
     | 
    
         
            +
                </div>
         
     | 
| 
      
 9 
     | 
    
         
            +
              </div>
         
     | 
| 
      
 10 
     | 
    
         
            +
              <div class="button--double form-general-submit">
         
     | 
| 
      
 11 
     | 
    
         
            +
                <%= f.submit t(".create") %>
         
     | 
| 
      
 12 
     | 
    
         
            +
              </div>
         
     | 
| 
      
 13 
     | 
    
         
            +
            <% end %>
         
     | 
| 
         @@ -0,0 +1,40 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <% content_for :secondary_nav do %>
         
     | 
| 
      
 2 
     | 
    
         
            +
              <div class="secondary-nav">
         
     | 
| 
      
 3 
     | 
    
         
            +
                <div class="secondary-nav__title">
         
     | 
| 
      
 4 
     | 
    
         
            +
                  <%= t ".title" %>
         
     | 
| 
      
 5 
     | 
    
         
            +
                </div>
         
     | 
| 
      
 6 
     | 
    
         
            +
                <ul>
         
     | 
| 
      
 7 
     | 
    
         
            +
                  <li <% if is_active_link?(decidim_admin.edit_organization_path) %> class="is-active" <% end %>>
         
     | 
| 
      
 8 
     | 
    
         
            +
                    <%= link_to t("menu.configuration", scope: "decidim.admin"), decidim_admin.edit_organization_path %>
         
     | 
| 
      
 9 
     | 
    
         
            +
                  </li>
         
     | 
| 
      
 10 
     | 
    
         
            +
                  <li <% if is_active_link?(decidim_admin.edit_organization_appearance_path) %> class="is-active" <% end %>>
         
     | 
| 
      
 11 
     | 
    
         
            +
                    <%= link_to t("menu.appearance", scope: "decidim.admin"), decidim_admin.edit_organization_appearance_path %>
         
     | 
| 
      
 12 
     | 
    
         
            +
                  </li>
         
     | 
| 
      
 13 
     | 
    
         
            +
                  <li <% if is_active_link?(decidim_admin.edit_organization_homepage_path, /^\/admin\/organization\/homepage/) %> class="is-active" <% end %>>
         
     | 
| 
      
 14 
     | 
    
         
            +
                    <%= link_to t("menu.homepage", scope: "decidim.admin"), decidim_admin.edit_organization_homepage_path %>
         
     | 
| 
      
 15 
     | 
    
         
            +
                  </li>
         
     | 
| 
      
 16 
     | 
    
         
            +
                  <li <% if is_active_link?(decidim_admin_navbar_links.navbar_links_path) %> class="is-active" <% end %>>
         
     | 
| 
      
 17 
     | 
    
         
            +
                    <%= link_to t("menu.navbar_links", scope: "decidim_navbar_links.admin"), decidim_admin_navbar_links.navbar_links_path %>
         
     | 
| 
      
 18 
     | 
    
         
            +
                  </li>
         
     | 
| 
      
 19 
     | 
    
         
            +
                  <li <% if is_active_link?(decidim_admin.scopes_path) %> class="is-active" <% end %>>
         
     | 
| 
      
 20 
     | 
    
         
            +
                    <%= link_to t("menu.scopes", scope: "decidim.admin"), decidim_admin.scopes_path %>
         
     | 
| 
      
 21 
     | 
    
         
            +
                  </li>
         
     | 
| 
      
 22 
     | 
    
         
            +
                  <li <% if is_active_link?(decidim_admin.scope_types_path) %> class="is-active" <% end %>>
         
     | 
| 
      
 23 
     | 
    
         
            +
                    <%= link_to t("menu.scope_types", scope: "decidim.admin"), decidim_admin.scope_types_path %>
         
     | 
| 
      
 24 
     | 
    
         
            +
                  </li>
         
     | 
| 
      
 25 
     | 
    
         
            +
                  <li <% if is_active_link?(decidim_admin.areas_path) %> class="is-active" <% end %>>
         
     | 
| 
      
 26 
     | 
    
         
            +
                    <%= link_to t("menu.areas", scope: "decidim.admin"), decidim_admin.areas_path %>
         
     | 
| 
      
 27 
     | 
    
         
            +
                  </li>
         
     | 
| 
      
 28 
     | 
    
         
            +
                  <li <% if is_active_link?(decidim_admin.area_types_path) %> class="is-active" <% end %>>
         
     | 
| 
      
 29 
     | 
    
         
            +
                    <%= link_to t("menu.area_types", scope: "decidim.admin"), decidim_admin.area_types_path %>
         
     | 
| 
      
 30 
     | 
    
         
            +
                  </li>
         
     | 
| 
      
 31 
     | 
    
         
            +
                  <li <% if allowed_to?(:update, :help_sections) && is_active_link?(decidim_admin.help_sections_path) %> class="is-active" <% end %>>
         
     | 
| 
      
 32 
     | 
    
         
            +
                    <%= link_to t("menu.help_sections", scope: "decidim.admin"), decidim_admin.help_sections_path %>
         
     | 
| 
      
 33 
     | 
    
         
            +
                  </li>
         
     | 
| 
      
 34 
     | 
    
         
            +
                </ul>
         
     | 
| 
      
 35 
     | 
    
         
            +
              </div>
         
     | 
| 
      
 36 
     | 
    
         
            +
            <% end %>
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            <%= render "layouts/decidim/admin/application" do %>
         
     | 
| 
      
 39 
     | 
    
         
            +
              <%= yield %>
         
     | 
| 
      
 40 
     | 
    
         
            +
            <% end %>
         
     | 
| 
         @@ -0,0 +1,64 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            en:
         
     | 
| 
      
 3 
     | 
    
         
            +
              decidim:
         
     | 
| 
      
 4 
     | 
    
         
            +
                admin:
         
     | 
| 
      
 5 
     | 
    
         
            +
                  actions:
         
     | 
| 
      
 6 
     | 
    
         
            +
                    add: Add
         
     | 
| 
      
 7 
     | 
    
         
            +
                    confirm_destroy: Confirm destroy
         
     | 
| 
      
 8 
     | 
    
         
            +
                    destroy: Destroy
         
     | 
| 
      
 9 
     | 
    
         
            +
                    edit: Edit
         
     | 
| 
      
 10 
     | 
    
         
            +
                  menu:
         
     | 
| 
      
 11 
     | 
    
         
            +
                    appearance: Appearance
         
     | 
| 
      
 12 
     | 
    
         
            +
                    area_types: Area types
         
     | 
| 
      
 13 
     | 
    
         
            +
                    areas: Areas
         
     | 
| 
      
 14 
     | 
    
         
            +
                    configuration: Configuration
         
     | 
| 
      
 15 
     | 
    
         
            +
                    help_sections: Help sections
         
     | 
| 
      
 16 
     | 
    
         
            +
                    homepage: Homepage
         
     | 
| 
      
 17 
     | 
    
         
            +
                    navbar_links: Navbar links
         
     | 
| 
      
 18 
     | 
    
         
            +
                    scope_types: Scope types
         
     | 
| 
      
 19 
     | 
    
         
            +
                    scopes: Scopes
         
     | 
| 
      
 20 
     | 
    
         
            +
                  models:
         
     | 
| 
      
 21 
     | 
    
         
            +
                    navbar_link:
         
     | 
| 
      
 22 
     | 
    
         
            +
                      fields:
         
     | 
| 
      
 23 
     | 
    
         
            +
                        link: Link
         
     | 
| 
      
 24 
     | 
    
         
            +
                        title: Title
         
     | 
| 
      
 25 
     | 
    
         
            +
                        weight: Weight
         
     | 
| 
      
 26 
     | 
    
         
            +
                  navbar_links:
         
     | 
| 
      
 27 
     | 
    
         
            +
                    create:
         
     | 
| 
      
 28 
     | 
    
         
            +
                      error: Error
         
     | 
| 
      
 29 
     | 
    
         
            +
                      success: Success
         
     | 
| 
      
 30 
     | 
    
         
            +
                    destroy:
         
     | 
| 
      
 31 
     | 
    
         
            +
                      success: Success
         
     | 
| 
      
 32 
     | 
    
         
            +
                    no_links: No links
         
     | 
| 
      
 33 
     | 
    
         
            +
                    update:
         
     | 
| 
      
 34 
     | 
    
         
            +
                      error: Error
         
     | 
| 
      
 35 
     | 
    
         
            +
                      success: Success
         
     | 
| 
      
 36 
     | 
    
         
            +
                  titles:
         
     | 
| 
      
 37 
     | 
    
         
            +
                    navbar_links: Navbar Links
         
     | 
| 
      
 38 
     | 
    
         
            +
                components:
         
     | 
| 
      
 39 
     | 
    
         
            +
                  navbar_links:
         
     | 
| 
      
 40 
     | 
    
         
            +
                    name: NavbarLinks
         
     | 
| 
      
 41 
     | 
    
         
            +
                navbar_links:
         
     | 
| 
      
 42 
     | 
    
         
            +
                  admin:
         
     | 
| 
      
 43 
     | 
    
         
            +
                    navbar_links:
         
     | 
| 
      
 44 
     | 
    
         
            +
                      edit:
         
     | 
| 
      
 45 
     | 
    
         
            +
                        title: Title
         
     | 
| 
      
 46 
     | 
    
         
            +
                        update: Update
         
     | 
| 
      
 47 
     | 
    
         
            +
                      form:
         
     | 
| 
      
 48 
     | 
    
         
            +
                        link: Link
         
     | 
| 
      
 49 
     | 
    
         
            +
                        new_tab: New tab
         
     | 
| 
      
 50 
     | 
    
         
            +
                        same_tab: Same tab
         
     | 
| 
      
 51 
     | 
    
         
            +
                        title: Title
         
     | 
| 
      
 52 
     | 
    
         
            +
                        weight: Weight
         
     | 
| 
      
 53 
     | 
    
         
            +
                      new:
         
     | 
| 
      
 54 
     | 
    
         
            +
                        create: Create
         
     | 
| 
      
 55 
     | 
    
         
            +
                        title: Title
         
     | 
| 
      
 56 
     | 
    
         
            +
              decidim_navbar_links:
         
     | 
| 
      
 57 
     | 
    
         
            +
                admin:
         
     | 
| 
      
 58 
     | 
    
         
            +
                  menu:
         
     | 
| 
      
 59 
     | 
    
         
            +
                    navbar_links: Navbar links
         
     | 
| 
      
 60 
     | 
    
         
            +
              layouts:
         
     | 
| 
      
 61 
     | 
    
         
            +
                decidim:
         
     | 
| 
      
 62 
     | 
    
         
            +
                  admin:
         
     | 
| 
      
 63 
     | 
    
         
            +
                    settings:
         
     | 
| 
      
 64 
     | 
    
         
            +
                      title: Title
         
     | 
| 
         @@ -0,0 +1,28 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Decidim
         
     | 
| 
      
 4 
     | 
    
         
            +
              module NavbarLinks
         
     | 
| 
      
 5 
     | 
    
         
            +
                # This is the engine that runs on the public interface of `NavbarLinks`.
         
     | 
| 
      
 6 
     | 
    
         
            +
                class AdminEngine < ::Rails::Engine
         
     | 
| 
      
 7 
     | 
    
         
            +
                  isolate_namespace Decidim::NavbarLinks::Admin
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                  paths["db/migrate"] = nil
         
     | 
| 
      
 10 
     | 
    
         
            +
                  paths["lib/tasks"] = nil
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  routes do
         
     | 
| 
      
 13 
     | 
    
         
            +
                    resources :navbar_links
         
     | 
| 
      
 14 
     | 
    
         
            +
                    root to: "navbar_links#index"
         
     | 
| 
      
 15 
     | 
    
         
            +
                  end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                  initializer "decidim_navbar_links.admin_mount_routes" do
         
     | 
| 
      
 18 
     | 
    
         
            +
                    Decidim::Core::Engine.routes do
         
     | 
| 
      
 19 
     | 
    
         
            +
                      mount Decidim::NavbarLinks::AdminEngine, at: "/admin", as: "decidim_admin_navbar_links"
         
     | 
| 
      
 20 
     | 
    
         
            +
                    end
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                  def load_seed
         
     | 
| 
      
 24 
     | 
    
         
            +
                    nil
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "rails"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "decidim/core"
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            module Decidim
         
     | 
| 
      
 7 
     | 
    
         
            +
              module NavbarLinks
         
     | 
| 
      
 8 
     | 
    
         
            +
                # This is the engine that runs on the public interface of navbar_links.
         
     | 
| 
      
 9 
     | 
    
         
            +
                class Engine < ::Rails::Engine
         
     | 
| 
      
 10 
     | 
    
         
            +
                  isolate_namespace Decidim::NavbarLinks
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  initializer "decidim.menu" do
         
     | 
| 
      
 13 
     | 
    
         
            +
                    Decidim.menu :menu do |menu|
         
     | 
| 
      
 14 
     | 
    
         
            +
                      NavbarLink.organization(current_organization).each do |navbar_link|
         
     | 
| 
      
 15 
     | 
    
         
            +
                        menu.item translated_attribute(navbar_link.title),
         
     | 
| 
      
 16 
     | 
    
         
            +
                                  navbar_link.link,
         
     | 
| 
      
 17 
     | 
    
         
            +
                                  position: 5,
         
     | 
| 
      
 18 
     | 
    
         
            +
                                  active: :exact,
         
     | 
| 
      
 19 
     | 
    
         
            +
                                  target: navbar_link.target
         
     | 
| 
      
 20 
     | 
    
         
            +
                      end
         
     | 
| 
      
 21 
     | 
    
         
            +
                    end
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     |