Skip to content

Instantly share code, notes, and snippets.

@danil-z
Created January 30, 2011 11:55
Show Gist options
  • Save danil-z/802815 to your computer and use it in GitHub Desktop.
Save danil-z/802815 to your computer and use it in GitHub Desktop.
tabpanel.load
class JournalPanel < Netzke::Basepack::BorderLayoutPanel
js_property :header, false
def configuration
school_id = super[:school_id] || component_session[:selected_school_id].to_i
component_session[:selected_school_id] = school_id
school = School.find(school_id)
classroom_store = school.classrooms.order(:number,:letter).collect {|c|[c.id,c.title]}
super.merge(
:tbar => [{xtype: 'tbtext', :text => "#{I18n.t(:journal)} - #{school.title}, #{I18n.t('activerecord.attributes.classroom.title')}: "}, ' ',
{:name => :classroom, :id => :classroom, :xtype => :combo, :editable => false, :trigger_action => :all,
:store => classroom_store, :width => 50}, ' ',
{xtype: 'tbtext', :text => "#{I18n.t(:on_date)}: "}, ' ',
{:name => :jdate, :id => :jdate, :xtype => :datefield, :value => Time.now.strftime("%d/%m/%Y")}
],
:items => [ {:class_name => "Basepack::TabPanel", :name => :journal_pages, :id => :journal_pages, :region => :center,
:items => [{xtype: 'tbtext', :text=> I18n.t(:under_construction), :title =>I18n.t('activerecord.models.journal_content'),
}],:active_tab => 0
}]
)
end
# Overriding initComponent
js_method :init_component, <<-JS
function(){
// calling superclass's initComponent
#{js_full_class_name}.superclass.initComponent.call(this);
// setting the 'rowclick' event
this.getTopToolbar().findById("classroom").on('select', this.onClassroomChanged, this);
//this.getTopToolbar().findById("jdate").on('select', this.onJdateChanged, this);
}
JS
# # Event handler this.selectTypePeriod({type_period_id: self.store.getAt(rowIndex).get('id')});
js_method :on_classroom_changed, <<-JS
function(cb){
//var periodBox = Ext.getCmp("admin_simple_app__schedule_panel").getTopToolbar().findById("period");
var jdateValue = this.getTopToolbar().findById("jdate").getValue();
var classroomValue = cb.getValue();
if ((jdateValue) && (classroomValue)) {
var journalPages = this.findById("journal_pages");
//console.debug(journalPages);
//journalPages.load({url: '/netzke/admin_simple_app__journal_panel__get_newtabs', params: {classroom: classroomValue, jdate: jdateValue } });
var removedTabs = journalPages.removeAll();
journalPages.doLayout();
this.getNewtabs({classroom: classroomValue, jdate: jdateValue },function(){
journalPages.doLayout();
});
}
}
JS
endpoint :get_newtabs do |params|
{}.tap do |res|
res[:add] = [{:html=> 'sample tab 1', :title =>"tab1"}.to_json, {:html=> 'sample tab 2', :title =>"tab2"}.to_json]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment