Giter VIP home page Giter VIP logo

netzke-core's Introduction

Netzke Core Build Status Code Climate

RDocs

Netzke Core is the bare bones of the Netzke framework. For pre-built full-featured components (like grids, forms, tab/accordion panels, etc), see netzke-basepack.

Notes on versioning:

  • The latest released version is: Gem Version
  • The version under development (master): version.rb
  • For other versions check corresponding branches

For rationale and mini-tutorial, refer to the meta gem's README. The README you're reading explains the Netzke architecture in detail. Some knowledge of Sencha Ext JS may be required to fully understand this overview.

What is a Netzke component

A Netzke component is a Ruby class (further referred to as "server class"), which is being represented by an Ext JS Component on the server-side (further referred to as "client class"). The responsibility of the server class is to "assemble" the client class and provide the configuration for its instance (further referred as "client class instance"). Even if it may sound a bit complicated, Netzke provides a simple API for defining and configuring the client class. See Client class for details.

Further, each Netzke component inherits convenient API for enabling the communication between the client and server class. See Client-server interaction for details.

With Netzke components being a Ruby class, and the client class being incapsulated in it, it is possible to use a Netzke component in your application by simply writing Ruby code. However, while creating a component, developers can fully use their Ext JS skills - Netzke puts no obstacles here.

A typical Netzke component's code is structured like this (on example of MyComponent):

your_web_app
  app
    components
      my_component.rb             <-- the Ruby class
      my_component
        some_module.rb            <-- optional extra Ruby code
        client
          some_dependency.js      <-- optional external JS library
          init_component.js       <-- optional override ("include") to the client class
          extra_functionality.js  <-- more override
          my_special_button.css    <-- optional custom CSS

Client class

The generated client class is inherited (as defined by the Ext JS class system) from an Ext JS class, which by default is Ext.panel.Panel. For example, a component defined like this:

class HelloWorld < Netzke::Base
end

will have the following client class generated by Netzke (simplified):

Ext.define('Netzke.classes.HelloWorld', {"extend":"Ext.panel.Panel", "mixins":["Netzke.Base"]});

Netzke.Base contains a set of client class methods and properties common to every Netzke component.

Extending HelloWorld will be automatically reflected on the client-class level:

class HelloNewWorld < HelloWorld
end

will have the following client class generated (simplified):

Ext.define('Netzke.classes.HelloNewWorld', {"extend":"Netzke.classes.HelloWorld"});

Configuration of the client-class can be done by using the Netzke::Base.client_class. For example, in order to inherit from a different Ext JS component, and to mix in the methods defined in the client subfolder:

class MyTabPanel < Netzke::Base
  client_class do |c|
    c.extend = "Ext.tab.Panel"
    c.include :extra_functionality
  end
end

The code above will set the extend property to "Ext.tab.Panel", and will mix in the following scripts:

  • app/components/my_tab_panel/client/my_tab_panel.js (if that exists)
  • app/components/my_tab_panel/client/extra_functionality.js

For more details on defining the client class, refer to Netzke::Core::ClientClassConfig.

Composition

Any Netzke component can define child components, which can either be statically nested in the compound layout (e.g. as different regions of the 'border' layout), or dynamically loaded at a request (as in the case of the edit form window in Netzke::Basepack::GridPanel, for example).

Defining child components

You can define a child component by calling the component class method which normally requires a block:

component :users do |c|
  c.klass = GridPanel
  c.model = "User"
  c.title = "Users"
end

Nesting components

Declared components can be referred to in the component layout:

def configure(c)
  super
  c.items = [
    { xtype: :panel, title: "Simple Ext panel" },
    :users
  ]
end

Dynamic loading of components

Next to being statically nested in the layout, a child component can also be dynamically loaded by using client class' netzkeLoadComponent method:

this.netzkeLoadComponent('users');

this will load the "users" component and add it to the current container.

For more details on dynamic component loading refer to netzkeLoadComponent docs.

For more details on composition refer to Netzke::Core::Composition.

Actions, toolbars, and menus

Actions are used by Ext JS to share functionality and state among multiple buttons and menu items. Define actions with the action class method:

action :show_report do |c|
  c.text = "Show report"
  c.icon = :report
end

The icon for this button will be images/icons/report.png (see Icons support).

Refer to actions in toolbars:

def configure(c)
  super
  c.bbar = [:show_report]
end

Actions can also be referred to is submenus:

  c.tbar = [{text: 'Menu', menu: {items: [:show_report]}}]

For more details on composition refer to Netzke::Core::Actions.

Client-server interaction

Communication between the client class and the corresponding server class is done by means of defining endpoints. By defining an endpoint on the server, the client class automatically gets access to an equally named method that calls the server.

Calling an endpoint from client class

By defining an endpoint like this:

class SimpleComponent < Netzke::Base
  endpoint :whats_up do |greeting|
  # ...
  end
end

...the client class will obtain a method called whatsUp, that can be called on the this.server object like this:

this.server.whatsUp(greeting, callback, scope);

The last 2 params are optional:

  • callback - function to be called after the server successfully processes the endpoint call; the function will receive, as its only argument, the result of the endpoint block execution
  • scope - context in which the callback function will be called; defaults to the component's instance

As of version 1.0, the endpoint may receive an arbitrary number of arguments, for example:

this.server.doSomething('value 1', true, callback, scope);
class SimpleComponent < Netzke::Base
  endpoint :do_something do |arg_1, arg_2|
    # arg_1 == 'value 1'
    # arg_2 == true
  end
end

Calling client class methods from endpoint

An endpoint can instruct the client instance of the component to execute a set of methods in response, passing those methods arbitrary parameters, by using the client method. For example:

class SimpleComponent < Netzke::Base
  endpoint :whats_up_server do
    client.set_title("Response from server")
    client.my_method
  end
end

Here the client class will first call its setTitle method (defined in Ext.panel.Panel) with parameter passed from the endpoint. Then a custom method myMethod will be called with no parameters.

For more details on client-server communication see Netzke::Core::Services.

Icons support

Netzke can optionally make use of icons for making clickable elements like buttons and menu items more visual. The icons should be (by default) located in app/assets/images/icons.

An example of specifying an icon for an action:

action :logout do |c|
  c.icon = :door
end

The logout action will be configured with public/assets/icons/door.png as icon.

For more details on using icons refer to Netzke::Core::Actions.

I18n

Netzke Core will automatically include Ext JS localization files based on current I18n.locale.

Also, Netzke Core uses some conventions for localizing actions. Refer to Netzke::Core::Actions.

Routing

Any Netzke component can react on a specific hash-route in the URL, which can be achieved by specifying netzkeRoutes hash on the client class, similarly to how Ext JS handles routes in its controllers:

// e.g. in my_component/client/my_component.js
{
  netzkeRoutes: {
    'users': 'onUsers',
    'users/:id': 'onUser'
  },

  onUsers: function() {},

  onUser: function(userId) {},
}

If a component gets loaded dynamically and it figures out that one of its routes is currently active, it'll trigger the corresponding handler after being rendered.

Authentication and authorization

You can access the instance of the Netzke controller via Netzke::Base.controller. As it inherits from ApplicationController, it also has the access to the current_user if that is defined.

Requirements

  • Ruby >= 2.3.0
  • Rails ~> 5.1.0
  • Ext JS = 6.5.1

Installation

$ gem install netzke-core

For the latest ("edge") stuff, instruct the bundler to get the gem straight from github:

gem 'netzke-core', github: "netzke/netzke-core"

By default, Netzke assumes that your Ext JS library is located in public/extjs. It can be a symbolic link, e.g.:

$ ln -s PATH/TO/YOUR/EXTJS/FILES public/extjs

(Make sure that the location of the license.txt distributed with Ext JS is exactly public/extjs/license.txt)

Running tests

The bundled spec/rails_app application used for automated testing can be easily run as a stand-alone Rails app. It's a good source of concise, focused examples. After starting the application, access any of the test components (located in spec/rails_app/app/components) by using the following url:

http://localhost:3000/netzke/components/{name of the component's class}

For example http://localhost:3000/netzke/components/Endpoints

To run a specific Mocha JS spec (located in spec/mocha) for a component, append ?spec={name of spec}, for example:

[http://localhost:3000/netzke/components/Endpoints?spec=endpoints](http://localhost:3000/components/Endpoints?spec=endpoints)

To run all the tests (from the gem's root):

$ rake

This assumes that the Ext JS library is located/symlinked in spec/rails_app/public/extjs. If you want to use Sencha CDN instead, run:

$ EXTJS_SRC=cdn rake

Contributions and support

Help developing Netzke by submitting a pull request when you think others can benefit from it.

If you feel particularily generous, you can support the author by donating a couple bucks a week at GitTip.

Useful links


Copyright (c) 2009-2017 Good Bit Labs, released under the same license as Ext JS

netzke-core's People

Contributors

0rca avatar allomov avatar avsej avatar delwyn avatar eddietejeda avatar firemind avatar kristianmandrup avatar mindreframer avatar randaalex avatar spieker avatar thepry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

netzke-core's Issues

undefined method `javascripts'

Running Ruby 1.9.2p0 with Gems 1.3.7 I downloaded netzke-demo ran bundle install and then started server. I get this traceback:
/home/vagrant/.bundler/ruby/1.9.1/netzke-basepack-48e8566cf7cc/lib/netzke/basepack.rb:13:in init': undefined methodjavascripts' for Netzke::Core:Module (NoMethodError)
from /home/vagrant/.bundler/ruby/1.9.1/netzke-basepack-48e8566cf7cc/lib/netzke-basepack.rb:26:in <top (required)>' from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.3/lib/bundler/runtime.rb:64:inrequire'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.3/lib/bundler/runtime.rb:64:in block (2 levels) in require' from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.3/lib/bundler/runtime.rb:62:ineach'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.3/lib/bundler/runtime.rb:62:in block in require' from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.3/lib/bundler/runtime.rb:51:ineach'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.3/lib/bundler/runtime.rb:51:in require' from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/bundler-1.0.3/lib/bundler.rb:112:inrequire'
from /shared/netzke_demo/config/application.rb:7:in <top (required)>' from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:28:inrequire'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:28:in block in <top (required)>' from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:27:intap'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:27:in <top (required)>' from script/rails:6:inrequire'
from script/rails:6:in `

'
Please advise. Thanks

Overriding scope in component declaration has no effect

When a scope is set in component configuration:

class FooGrid < Grid
  def configure c
    super c
    c.scope = :foo_scope
  end
end

I am not able to override it via the component declaration:

component :foo_grid do |c|
  c.klass = FooGrid
  c.scope = :other_scope
end

As soon as I remove the scope from the configure method the scope supplied in the
declaration will be honored.

Not entirely sure if basepack or core is at fault but I assume it has something to do with the merging mechanism of the different config layers so I reported it here.

The theme support is not working

I've just tried to change the theme for my application but it didn't work. In the ActionViewExt I was looking for some references to 'theme' or 'ext_theme' but none of these options is really used.

{widget}_widget_instance is cached and never expired

i updated the columns of a netzke action, and the changes never get into my views. Only when i rename the action the columns are updated, so i am at sellers_12 now and it really looks silly :(
restarting the server/apache/ruby-process did not help...

NameError (uninitialized constant Netzke::Basepack::GridPanel::Services::JSON):

Hi Sergey.

I am encountering this very same issue although it had been previously closed. I have tried a very basic app and this error is encountered when trying to filter via the column header. The error persists until any filtering is removed.

I am running on mac os x so the Ruby version is 1.8.7. I have tried this with both EXT version 3.3.1 and 4 ( using your master and extjs4 branches).

Any ideas?

Richard

Help please, Hello_World tutorial not working with Rails 3.0.9/Ruby 1.9.3/Ext 4.0.7/Windows 7

Well I followed the Hello_World tutorial in the Wiki to the letter.
When I start up my server, I get the error:
uninitialized constant HelloWorldComponent
I created the folder components as a subfolder of the app folder
I created the file hello_world_component.rb as described in the Wiki tutorial
I cut and paste the code for the component into the file and saved it
I did everything else as described in the Wiki

Anyone else starting out like me? I have got Netzke working before but with extjs 3.0 and Rails 2.3 please help!

Thanks

Couldn't load component cmp1 error when dynamically loading tab in workspace

Environment: Ruby 2.0 Rails 4.0 netzke-core 0.90 netzke-base 0.9.0 netzke-communitypack 0.80
When trying to load a component into a tab using the netzke Workspace, I get the error "Couldn't load component cmp1" error. I tracked the error to the Netzke::Core::Composition module, specifically the deliver_component endpoint. In this method, the line of code;

'''cmp_instance = components[component_name] &&
!components[component_name][:excluded] &&
component_instance(component_name, {item_id: item_id, client_config: params[:client_config]})'''

cmp_instance should be returning a component line "UserGrid" which would be inserted into the tab, it is returning nil instead when it shouldn't.
I traced the problem further to the function call 'component_instance' that is called in that expression. I'm by no means completely familiar with Netzke code, but this where my understanding of the code is sparse. I noted that Max had made significant changes to the code for the component_instance method, as a matter of fact the code was completely replaced from the older working version. The new code seems to expect that any child components should have a method 'child component name'_component present in the parent component's code. I looked every where and cannot find where this method is dynamically inserted prior to this component_instance method being called, as a result 'component_instance' will always return nil. Just verify my theory, I monkey patched in the old code that was there before the code change, and low and behold components correctly get inserted into Workspace tabs. Can you please look into this Max? Thanks for creating Netzke btw, big fan!

Wiki tutorial

I start learn netzke gem from its wiki and got issue in the "hello world" app. The problem is in bottom bar configuration:

js_property :bbar, [:bug_server.action]
action :bug_server, :text=>"foo message"

In chrome js console I got 'undefined method bug_server'. When I remove '.action' part error gone, but it render only text label in bottom bar. Its a new API or issue in version 0.74?

Redundant inclusion of JS/CSS

If I have a simple component that extends GridPanel, e.g.,

class ExpandableGridPanel < Netzke::Basepack::GridPanel
js_include Netzke::Core.ext_location.join("examples/ux/
RowExpander.js"),
css_include "#{File.dirname(FILE)}/ajaxrowexpander/
RowExpander.css"

[other stuff here...]
end

and then i create a tab panel, e.g,

<%= netzke :tabs,
:class_name => "Basepack::TabPanel",
:items => [
{:class_name => 'ExpandableGridPanel', :model => 'User'},
{:class_name => 'ExpandableGridPanel', :model =>
'Membership'},
{:class_name => 'ExpandableGridPanel', :model => 'Asset'},
[several more like the above...]
],
%>

Then I get the js and css files included numerous times, once for each
time the class is used.

Configuration for netzke default routes

I need a possibility to change the netzke default route (incl. controller) to another path.
Is there a config who I can configure the default netzke route and controller?

Example:

#From
/netzke/(:action)

#To
/some/path/netzke/(:action)

Netzke can not work

I follow this tutorial step by step. My ruby version is 1.9.3, and rails version is 3.2.16.

But still can not work. throw me an error:

NameError

undefined local variable or method `netzke' for #<ActionDispatch::Routing::Mapper:0x007ffcb24eb590>

Rails.root: /Users/USER/MyGit/a

It seems the root error, so I change the root file

before:

 netzke
  root to: "welcome#index"

after:

  root to: "welcome#index"

But when run again, It throw me another error:

NoMethodError in Welcome#index

Showing /Users/tangmonk/MyGit/a/app/views/welcome/index.html.erb where line #1 raised:

undefined method `netzke' for #<#<Class:0x007ffcb29cad40>:0x007ffcb29c8248>
Extracted source (around line #1):

1: <%= netzke :tasks, height: 400 %>
Rails.root: /Users/tangmonk/MyGit/a

I change the rails version to 4.0, But problem still exist.

@nomadCoder , I notice you are the most important contributor of this project, So I hope you can help me. Thanks

quest about netzke_init

<script src="/extjs/adapter/ext/ext-base-debug.js?1293439905" type="text/javascript"></script> <script src="/extjs/ext-all-debug.js?1293440262" type="text/javascript"></script> <script src="/netzke/ext.js?1293618927" type="text/javascript"></script>

the helper can generate above code ๏ผŒbut no rake task can help to generate /netzke/ext.js and /netzke/ext.js . In my view , the core.js must need, but also no task to generate it in the /netzke folder and the netzke_init doesn't include it.

I follow below document but not work:
https://github.com/skozlov/netzke-core/wiki/Installation
https://github.com/skozlov/netzke-core/wiki/Hello-world-extjs
my

undefined method `current_user' for Netzke::Core:Module

Hi folks,
I tried to upgrade our existing netzke app from 0.7.7 to 0.8.1 today. And somehow netzke got rid of the very handy Netzke::Core.current_user helper. Did it get lost with the 0.8 upgrade or is this intentional?

Also netzke-cancan assumes, that this method ist present.

If people should use Netzke::Base.controller.current_user, then this issue can be closed.

Netzke::Basepack::GridPanel::RecordFormWindow have unoverridable config

Its preferable to use

def default_instance_config
{
:modal => true,
:width => "50%",
:auto_height => true,
:fbar => [:ok.action, :cancel.action]
}
end

instead of @config@ class method to define config because the config defines weak_final_config that merges the all others. So, for example there no easy way to set edit window to maximize or allow to change height.

Actions can not be added to menu

http://www.rubydoc.info/github/netzke/netzke-core#Actions__toolbars__and_menus

Actions can also be referred to is submenus:
c.tbar = [{text: 'Menu', menu: {items: [:show_report]}}]

I played with netzke-demo, and change the Applcaction.rb title_html to menu like this:

tbar: [{text:'Menu', menu: {items: [:about]} },'->', :about, current_user ? :sign_out : :sign_in],

The dropdown menu displayed without any text and can not response to the click events.

When viewed source in chrome, I got ๏ผš

Ext.onReady(function(){
Netzke.page.application = Ext.create("widget.application", {"className":"Application","name":"application","introHtml":"Click on a demo component in the navigation tree",
"items":[{"layout":"border","tbar":[{"text":"Menu","menu":{"items":[{"action":"about"}]}},"-\u003e",{"action":"about"},{"action":"signIn"}],"items":[{"region":"west","itemId":"navigation","width":300,"split":true,"xtype":"treepanel",

Error running server

Ruby 1.9.3
Rails 3.2.1

Running rails server:

/Users/beb4ch/.rvm/gems/ruby-1.9.3-p125/bundler/gems/netzke-core-1c1ccc31355b/lib/netzke/services.rb:60:in register_endpoint': undefined methodread_inheritable_attribute' for Netzke::Base:Class (NoMethodError)
from /Users/beb4ch/.rvm/gems/ruby-1.9.3-p125/bundler/gems/netzke-core-1c1ccc31355b/lib/netzke/services.rb:37:in endpoint' from /Users/beb4ch/.rvm/gems/ruby-1.9.3-p125/bundler/gems/netzke-core-1c1ccc31355b/lib/netzke/composition.rb:33:inblock in module:Composition'
from /Users/beb4ch/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.1/lib/active_support/concern.rb:117:in class_eval' from /Users/beb4ch/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.2.1/lib/active_support/concern.rb:117:inappend_features'
from /Users/beb4ch/.rvm/gems/ruby-1.9.3-p125/bundler/gems/netzke-core-1c1ccc31355b/lib/netzke/base.rb:40:in include' from /Users/beb4ch/.rvm/gems/ruby-1.9.3-p125/bundler/gems/netzke-core-1c1ccc31355b/lib/netzke/base.rb:40:inclass:Base'
from /Users/beb4ch/.rvm/gems/ruby-1.9.3-p125/bundler/gems/netzke-core-1c1ccc31355b/lib/netzke/base.rb:33:in <module:Netzke>' from /Users/beb4ch/.rvm/gems/ruby-1.9.3-p125/bundler/gems/netzke-core-1c1ccc31355b/lib/netzke/base.rb:17:in<top (required)>'
from /Users/beb4ch/.rvm/gems/ruby-1.9.3-p125/bundler/gems/netzke-core-1c1ccc31355b/lib/netzke-core.rb:4:in require' from /Users/beb4ch/.rvm/gems/ruby-1.9.3-p125/bundler/gems/netzke-core-1c1ccc31355b/lib/netzke-core.rb:4:in<top (required)>'
from /Users/beb4ch/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.0.22/lib/bundler/runtime.rb:68:in require' from /Users/beb4ch/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.0.22/lib/bundler/runtime.rb:68:inblock (2 levels) in require'
from /Users/beb4ch/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.0.22/lib/bundler/runtime.rb:66:in each' from /Users/beb4ch/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.0.22/lib/bundler/runtime.rb:66:inblock in require'
from /Users/beb4ch/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.0.22/lib/bundler/runtime.rb:55:in each' from /Users/beb4ch/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.0.22/lib/bundler/runtime.rb:55:inrequire'
from /Users/beb4ch/.rvm/gems/ruby-1.9.3-p125/gems/bundler-1.0.22/lib/bundler.rb:122:in require' from /Users/beb4ch/SoftwareDevelopment/Workspaces/rails/money/config/application.rb:7:in<top (required)>'
from /Users/beb4ch/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.1/lib/rails/commands.rb:53:in require' from /Users/beb4ch/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.1/lib/rails/commands.rb:53:inblock in <top (required)>'
from /Users/beb4ch/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.1/lib/rails/commands.rb:50:in tap' from /Users/beb4ch/.rvm/gems/ruby-1.9.3-p125/gems/railties-3.2.1/lib/rails/commands.rb:50:in<top (required)>'
from script/rails:6:in require' from script/rails:6:in

'

Compatibility with Rails asset pipeline or a CDN

Right now I am only able to load javascripts from /public. I am unable to load from vendor/assets or from the CDN at : http://cdn.sencha.io/ext-4.1.0-gpl/

I used an initializer as follows:

Netzke::Core.setup do |config|
  config.ext_uri = 'assets'
end
Netzke::Core.setup do |config|
  config.ext_uri = 'http://cdn.sencha.io/ext-4.1.0-gpl'
end

using 'assets' as a prefix causes a linktag of:
http://localhost:3000/assets/assets/ext-all-debug.js

expecting it to be:
http://localhost:3000/assets/ext-all-debug.js

Using the CDN gives the following, no .js because it does not find the JS file:
http://cdn.sencha.io/ext-4.1.0-gpl/ext-all-debug

(should be http://cdn.sencha.io/ext-4.1.0-gpl/ext-all-debug.js)

I think the best way is to support
config.action_controller.asset_host

_uri if present would override using the asset_host based link tags.

Otherwise we should specify a prefix (with a default of 'assets') so that files can be put in /vendor/assets as Rails guides recommends. Using public is deprecated with the Rails asset pipeline.

Loading of nested components fails

Hi,

I have the following setup:

class App < Netzke::Basepack::SimpleApp
  [...]
  js_method :init_component, <<-JS
    function(){
      [...]
      // Load the main component
      this.appLoadComponent('main');
    }
  JS

  component :main, :class_name => "Main"
end
class Main < Netzke::Basepack::TabPanel
  def configuration
    res = super
    res.merge(items => [:sub_component.component])
  end

  component :sub_component, :class_name => "SubComponent"
end
class SubComponent < Netzke::Basepack::TabPanel
  def configuration
    res = super
    res.merge(items => [:sub_sub_component.component])
  end

  component :sub_sub_component, :class_name => "SubSubComponent"
end

What happens, after this.appLoadComponent('main'); is executed, is that netzke complains that it can't find sub_sub_component:
Netzke: unknown component reference sub_sub_subcomponent

I guess, the reason for that is the fact that

detectComponents

just checks this.netzkeComponents and doesn't go any deeper.
But that's just a guess.

The following patch in base.js fixed it for me:

detectComponents: function(o, netzkeComponents){
  if(netzkeComponents == null){
     netzkeComponents = this.netzkeComponents;
  }
  if (Ext.isObject(o)) {
    if (o.items) this.detectComponents(o.items);
  } else if (Ext.isArray(o)) {
    var a = o;
    Ext.each(a, function(c, i){
      if (c.netzkeComponent) {
        var cmpName = c.netzkeComponent,
            cmpCfg = netzkeComponents[cmpName.camelize(true)];
        if (!cmpCfg) throw "Netzke: unknown component reference " + cmpName;
        a[i] = Ext.apply(cmpCfg, c);
        delete a[i].netzkeComponent; // not needed any longer
      } else if (c.items) {this.detectComponents(c.items, c.netzkeComponents);}
    }, this);
  }
}

NameError (uninitialized constant Netzke::Basepack::GridPanel::Services::JSON):

Creating test application as descibed at
http://blog.writelesscode.com/blog/2010/06/14/extjs-rails-crud-application-in-7-minutes/

Started POST "/netzke/direct/?authenticity_token=i2HM%2BROEprbZtxRyZfcWxXHXfZYo13MEzvg1%2BDPTtbw%3D" for 127.0.0.1 at Fri Mar 04 14:01:06 +0300 2011
Processing by NetzkeController#direct as HTML
Parameters: {"data"=>[{"filter"=>"[{"type":"date","comparison":"gt","value":"03/18/2011","field":"due"}]", "start"=>0, "limit"=>30}], "method"=>"getData", "tid"=>3, "authenticity_token"=>"i2HM+ROEprbZtxRyZfcWxXHXfZYo13MEzvg1+DPTtbw=", "type"=>"rpc", "act"=>"tasks"}
Completed in 56ms

NameError (uninitialized constant Netzke::Basepack::GridPanel::Services::JSON):

Ruby 1.8.7-p334
Extjs 3.3.1

$ bundle
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.3)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.3)
Using erubis (2.6.6)
Using rack (1.2.1)
Using rack-mount (0.6.13)
Using rack-test (0.5.7)
Using tzinfo (0.3.24)
Using actionpack (3.0.3)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.15)
Using actionmailer (3.0.3)
Using arel (2.0.9)
Using activerecord (3.0.3)
Using activeresource (3.0.3)
Using acts_as_list (0.1.2)
Using bundler (1.0.10)
Using cgi_multipart_eof_fix (2.5.0)
Using daemons (1.1.0)
Using fastthread (1.0.7)
Using gem_plugin (0.2.3)
Using meta_where (1.0.4)
Using mongrel (1.1.5)
Using mysql2 (0.2.6)
Using netzke-core (0.6.6)
Using will_paginate (3.0.pre2)
Using netzke-basepack (0.6.4)
Using thor (0.14.6)
Using railties (3.0.3)
Using rails (3.0.3)

Ext location configure

config/initializers/netzke.rb:2:in block in <top (required)>': undefined methodext_location=' for Netzke::Core:Module (NoMethodError).

undefined method `new' for nil:NilClass after bundle update

Hi skozlov

I updated both basepack and core today then I get these error, the stack trace doesn't very helpful for me to debug, might you have some idea or I've miss something?

netzke-basepack-c2f2fda10dca
netzke-core-bc9cd6007b94

Once I revert to netzke-basepack-f4c263cb257f and netzke-core-12a68583a395 then the problem gone.

Started GET "/welcome/index" for 127.0.0.1 at 2010-12-24 17:19:25 +0800
Processing by WelcomeController#index as HTML
Rendered welcome/index.html.erb within layouts/application (87.9ms)
Completed in 99ms

ActionView::Template::Error (undefined method new' for nil:NilClass): 1: <%= netzke :simple_basic_app %> app/views/welcome/index.html.erb:1:in_app_views_welcome_index_html_erb__617632484852304534_16927740__2037854811478141187'

Rendered /home/idler/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.6ms)
Rendered /home/idler/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (5.6ms)
Rendered /home/idler/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (12.5ms)

Upgrading to sencha 5?

Hi there, as stated on the sencha website, upgrading to sencha 5 should be pretty straightforward, however when I tried just replacing the ext folder with the new release it completely bombed, I tried looking into it, I am guessing because netzke is linking to example code that is no longer there, the folder structure of the package seems to have changed. I tried to look at it, but quickly got swamped, to be honest I do not quite understand or "get" sencha yet, since using netzke I don't really need to ๐Ÿ˜„

The new sencha promises to be able to work on tablets, looks really cool imho, so switching would be really awesome. Any ideas or suggestions to take this forward?

Rails 3.2 support

Netzke is not working in rails 3.2. App cannot start because of read/write_inheritable_attribute call. instead of setter and getter methods, rails 3.2 uses class_attribute[:attr] for read/write (I think).

Also there is a deprecation warning for ActiveConcern.

Dynamic component loading broken

Hei Denis,

I've started to migrate an existing netzke app from 0.7.7 to the latest master, but I can't get it to work. Dynamic component loading always fails. I use Netzke::Basepack::SimpleApp, which has another component, that should be loaded.

I get the following error:

V8::JSError (Cannot call method 'ns' of null):
  at <eval>:2:5
  /home/meyer/.rvm/gems/ruby-1.9.3-p194-perf@blackbeard/bundler/gems/netzke-core-d02cb9f3aa2e/lib/netzke/composition.rb:86:in `block (2 levels) in <module:Composition>'
[...]

So the serverside JS evaluation complains when executing this piece of code:

Ext.ns("Netzke.classes.Home");

So it seems to me, as the server can't properly load ExtJS, right?

If you need more information, let me know.

Thanks for looking into this.

cheers,
Georg

netzke 0.8.4 can not work on rails 4.0.2

when I add "netzke" to route

$ rake routes

rake aborted!
You should not use the `match` method in your router without specifying an HTTP method.
If you want to expose your action to both GET and POST, add `via: [:get, :post]` option.
If you want to expose your action to GET, use `get` in the router:
  Instead of: match "controller#action"
  Do: get "controller#action"
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:191:in `normalize_conditions!'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:67:in `initialize'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1443:in `new'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1443:in `add_route'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1422:in `decomposed_match'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1403:in `block in match'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1394:in `each'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1394:in `match'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/netzke-core-0.8.4/lib/netzke/core/railz/routes.rb:18:in `netzke'
/Users/tangmonk/MyGit/VideoDeviceManagement/config/routes.rb:2:in `block in <top (required)>'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:341:in `instance_exec'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:341:in `eval_block'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:319:in `draw'
/Users/tangmonk/MyGit/VideoDeviceManagement/config/routes.rb:1:in `<top (required)>'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `block in load'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `each'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `load_paths'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:16:in `reload!'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:26:in `block in updater'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.2/lib/active_support/file_update_checker.rb:75:in `call'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.2/lib/active_support/file_update_checker.rb:75:in `execute'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:27:in `updater'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:6:in `execute_if_updated'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `instance_exec'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `run'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2/lib/rails/initializable.rb:54:in `run_initializers'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2/lib/rails/application.rb:215:in `initialize!'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/tangmonk/MyGit/VideoDeviceManagement/config/environment.rb:5:in `<top (required)>'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2/lib/rails/application.rb:189:in `require_environment!'
/Users/tangmonk/.rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2/lib/rails/application.rb:250:in `block in run_tasks_blocks'
Tasks: TOP => routes => environment
(See full trace by running task with --trace)

Well, since not supported rails 4, but why readme says support rails ~> 4 ?

can't use Ext.form.panel with directSubmit type to directly communicate with endpoint

when i use Ext.form.panel set config:

Ext.create('Ext.form.Panel', {
        //some configure
        api: {
          submit: Netzke.providers[_this.id].search
        },
        buttons: [{
          {
          text: 'Search',
          handler: function() {
            var form = this.up('form').getForm();
            if (form.isValid()) {
              form.submit({
                params: {name: 'aaa'},
              });
            }
          }
        }],
       //some configure

i hope it send request with params: "name" => "aaa", but i get this:{"path":"application__tp_panel__requirements_management__requirements_tree","endpoint":"search","data":[undefined],"tid":3}
so i review code,i found in (extjs api)[http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.Basic] config options api say: The formHandler configuration (see Ext.direct.RemotingProvider#action) must be set on the associated server-side method which has been imported by Ext.direct.Manager.
but netzke doesn't provide support to set endpoint formHandler true, in https://github.com/netzke/netzke-core/blob/ext42/javascripts/ext.js#L82-L91

  addEndpointsForComponent: function(componentPath, componentId, endpoints) {
    var cls = this.namespace[componentId] || (this.namespace[componentId] = {});

    Ext.Array.each(endpoints, function(ep) {
      var methodName = ep.camelize(true),
           //some endpoint should have config["formHandler"] = true
          method = Ext.create('Ext.direct.RemotingMethod', {name: methodName, len: 1});

        cls[methodName] = this.createHandler(componentPath, method);
    }, this);
  },

Default has_many does not update association

I created two models without explicitly specifying associations in Netzke.

class User < ActiveRecord::Base
  attr_accessible :email, :name
  has_many :pages
end

class Page < ActiveRecord::Base
  belongs_to :user
  attr_accessible :name, :url
end

class Pages < Netzke::Basepack::Grid
  def configure(c)
    super
    c.model = "Page"
  end
end

When I'm editing Page, it does update all the attributes except User. I selected User from drop-down list, but its parameter passed to netzke controller looks incorrect: \"user__name\":1 and in result user_id after updating is nil.

I've put code into repository: https://github.com/denispeplin/extjs_tut/tree/ne (uses netzke from gem in this tag, but I also tried with current netzke, same issue).

Post parameters:

Started POST "/netzke/direct/?authenticity_token=BaQAb8Gnadh6G3SkUZyY1nyA3S6fJACWEdwZN4FQZDI%3D" for 127.0.0.1 at 2013-01-22 10:08:18 +0400
Processing by NetzkeController#direct as HTML
  Parameters: {"act"=>"pages__edit_window__edit_form", "method"=>"netzkeSubmit", "data"=>[{"data"=>"{\"id\":\"2\",\"name\":\"testpage\",\"url\":\"www.example.com\",\"user__name\":1,\"created_at\":\"2013-01-21 12:19:56\",\"updated_at\":\"2013-01-22 05:01:39\"}"}], "type"=>"rpc", "tid"=>5, "authenticity_token"=>"BaQAb8Gnadh6G3SkUZyY1nyA3S6fJACWEdwZN4FQZDI=", "netzke"=>{"act"=>"pages__edit_window__edit_form", "method"=>"netzkeSubmit", "data"=>[{"data"=>"{\"id\":\"2\",\"name\":\"testpage\",\"url\":\"www.example.com\",\"user__name\":1,\"created_at\":\"2013-01-21 12:19:56\",\"updated_at\":\"2013-01-22 05:01:39\"}"}], "type"=>"rpc", "tid"=>5}}

Not sure it is netzke-core issue, maybe it is just component does not work properly.

bundle install error with 0.7.5

When running bundle install getting the following error:

Using netzke-core (0.7.5) from git://github.com/skozlov/netzke-core.git (at master) 
netzke-core at /Users/dmytro/.bundler/ruby/1.9.1/netzke-core-2d7e9380b1f7 did not have a valid gemspec.
This prevents bundler from installing bins or native extensions, but that may not affect its functionality.
The validation message from Rubygems was:
  [".travisrc", "lib/netzke/core_ext/class.rb"] are not files

Netzke with Mongoid (ActiveModel)

Hi,
I am looking at using Netzke with Mongoid however it relies on ActiveRecord. Is there any work / thoughts on removing netzke's dependance on ActiveRecord and replacing it with ActiveModel?

Cheers

Calling for a endpoint causes the entire config tree branch to be parsed.

There should be ability to make some components cachable, so endpoints calls on them should not parse entire application config.

For example consider such components: main -> sub -> c. So when calling endpoin defined on c, we get both main, sub and c configs parsed. It will be good to have opportunity to make c accessible directly.

Status 4.2 integration?

Hi, not entirely sure if this is the correct place, but I am curious what the status is of the migration to Extjs 4.2? I see there is a branch, is it useable?

I am starting a new project, a website to show geographical data, and I want to use extjs 4.2 and rails (and openlayers). At the moment geoext is too much for me I guess.

I am at the moment choosing between two possible alternatives: your gem/approach or the more manual approach and using the extjs4-rails gem.

What are your thoughts?

Dependent model saving

Two classes were created

class Supplier < ActiveRecord::Base  

  has_one :account, foreign_key: "acc_sup_id", :autosave => true  

  self.primary_key = 'sup_id'  

  attr_accessible :name, :remark

end  

class Account < ActiveRecord::Base 

  belongs_to :supplier, foreign_key: "acc_sup_id"  

  self.primary_key = 'acc_id'  

  self.table_name = 'accounts'  

  attr_accessible :dep, :rev

end

and netzke form is given as

class SupplierForm < Netzke::Basepack::Form

    def configure(c)

    c.model = 'Supplier'

    super

    c.items = [

      {field_label: "Name", name: :name},

      {field_label: "Remark", name: :remark},

      {field_label: "Dep", name: :account__dep, xtype: :checkbox, nested_attribute: true},

      {field_label: "Rev", name: :account__rev, xtype: :checkbox, nested_attribute: true}      
    ]

  end

end

Here I am getting two issues while saving

  1. while inserting only name and remark is saved but not the nested attributes.
  2. If the nested attribute fields set to checked the value is updated to DB but if unchecked update is not working

String#jsonify for '_meta'

There have been some changes in the ActiveSupport::Inflector class since Rails 3.2.0:

#  rails 3.1.x:
'_meta'.camelize(:lower) # => '_meta'
# rails 3.2.x:
'_meta'.camelize(:lower) # => 'Meta'

So this breaks String#jsonify as well as Symbol#jsonify.

Components in tbar, dockedItems etc.

Hi,

I tried to add a component to a tbar the following way:

def configuration
  super.merge({:tbar =>  [:my_combobox.component], ... })
end

component :my_combobox, ...

But it seems like that tbar, dockedItems, etc are not checked for NetzkeComponents, just the items property.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.