mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 08:55:44 +01:00
rebuild sonia.navigation
This commit is contained in:
@@ -102,3 +102,7 @@ a:visited {
|
|||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
margin-left: 2px;
|
margin-left: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.scm-nav-item {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
@@ -33,97 +33,89 @@ Ext.ns('Sonia.navigation');
|
|||||||
|
|
||||||
Sonia.navigation.NavSection = Ext.extend(Ext.Panel, {
|
Sonia.navigation.NavSection = Ext.extend(Ext.Panel, {
|
||||||
|
|
||||||
data: null,
|
links: null,
|
||||||
|
tpl: new Ext.XTemplate(
|
||||||
|
'<ul class="scm-nav-list">',
|
||||||
|
'<tpl for="links">',
|
||||||
|
'<li class="scm-nav-item">',
|
||||||
|
'<a id="{id}" class="scm-nav-item">{label}</a>',
|
||||||
|
'</li>',
|
||||||
|
'</tpl>',
|
||||||
|
'</ul>'
|
||||||
|
),
|
||||||
|
|
||||||
|
|
||||||
initComponent: function(){
|
initComponent: function(){
|
||||||
if ( this.data == null ){
|
if ( this.links == null ){
|
||||||
this.data = this.items;
|
this.links = this.items;
|
||||||
}
|
}
|
||||||
if ( this.data == null ){
|
if ( this.links == null ){
|
||||||
this.data = [];
|
this.links = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ext.each(this.links, function(link){
|
||||||
|
Ext.id( link );
|
||||||
|
});
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
frame: true,
|
frame: true,
|
||||||
collapsible:true,
|
collapsible:true,
|
||||||
style: 'margin: 5px',
|
style: 'margin: 5px'
|
||||||
listeners: {
|
|
||||||
afterrender: {
|
|
||||||
fn: this.renderMenu,
|
|
||||||
scope: this
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||||
Sonia.navigation.NavSection.superclass.initComponent.apply(this, arguments);
|
Sonia.navigation.NavSection.superclass.initComponent.apply(this, arguments);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onItemClick: function(e, t){
|
doAction: function(e, t){
|
||||||
var target = Ext.get(t);
|
console.debug( t );
|
||||||
var id = target.id;
|
e.stopEvent();
|
||||||
var prefix = this.id + '-nav-item-';
|
Ext.each(this.links, function(navItem){
|
||||||
if ( id != null && id.indexOf(prefix) == 0 ){
|
if ( navItem.id == t.id && Ext.isFunction(navItem.fn) ){
|
||||||
var i = parseInt( id.substring( prefix.length ) );
|
var scope = navItem.scope;
|
||||||
var fn = this.data[i].fn;
|
|
||||||
if ( Ext.isFunction( fn ) ){
|
|
||||||
var scope = this.data[i].scope;
|
|
||||||
if ( Ext.isObject( scope )){
|
if ( Ext.isObject( scope )){
|
||||||
fn.call(scope);
|
navItem.fn.call(scope);
|
||||||
} else {
|
} else {
|
||||||
fn();
|
navItem.fn();
|
||||||
}
|
|
||||||
} else if ( debug ){
|
|
||||||
console.debug('fn at "' + this.data[i].label + '" is not a function');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
renderMenu: function(){
|
afterRender: function(){
|
||||||
if ( Ext.isArray( this.data ) && this.data.length > 0 ){
|
Sonia.navigation.NavSection.superclass.afterRender.apply(this, arguments);
|
||||||
var links = [];
|
|
||||||
for ( var i=0; i<this.data.length; i++ ){
|
|
||||||
var item = this.data[i];
|
|
||||||
var link = {
|
|
||||||
tag: 'li',
|
|
||||||
cls: 'nav-item',
|
|
||||||
id: this.id + '-nav-item-' + i,
|
|
||||||
html: item.label,
|
|
||||||
style: 'cursor: pointer;'
|
|
||||||
};
|
|
||||||
links.push(link);
|
|
||||||
}
|
|
||||||
|
|
||||||
var dh = Ext.DomHelper;
|
// create list items
|
||||||
var list = dh.overwrite(this.body, {tag: 'ul', cls: 'nav-list'}, true);
|
this.tpl.overwrite(this.body, {
|
||||||
dh.append(list, links);
|
links: this.links
|
||||||
list.on('click', this.onItemClick, this);
|
});
|
||||||
}
|
|
||||||
|
this.body.on('mousedown', this.doAction, this, {delegate:'a'});
|
||||||
|
this.body.on('click', Ext.emptyFn, null, {delegate:'a', preventDefault:true});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
addLink: function(link){
|
addLink: function(link){
|
||||||
this.data.push(link);
|
Ext.id(link);
|
||||||
this.renderMenu();
|
this.links.push(link);
|
||||||
},
|
},
|
||||||
|
|
||||||
addLinks: function(links){
|
addLinks: function(links){
|
||||||
if ( Ext.isArray(links) && links.length > 0 ){
|
if ( Ext.isArray(links) && links.length > 0 ){
|
||||||
for ( var i=0; i<links.length; i++ ){
|
for ( var i=0; i<links.length; i++ ){
|
||||||
this.data.push(links[i]);
|
this.addLink(links[i]);
|
||||||
}
|
}
|
||||||
this.renderMenu();
|
|
||||||
} else {
|
} else {
|
||||||
this.addLink(links);
|
this.addLink(links);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
insertLink: function(pos, link){
|
insertLink: function(pos, link){
|
||||||
this.data.splice(pos, 0, link);
|
this.links.splice(pos, 0, link);
|
||||||
this.renderMenu();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
count: function(){
|
count: function(){
|
||||||
return this.data.length;
|
return this.links.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
|||||||
panel.addSection({
|
panel.addSection({
|
||||||
id: 'navMain',
|
id: 'navMain',
|
||||||
title: this.sectionMainText,
|
title: this.sectionMainText,
|
||||||
items: [{
|
links: [{
|
||||||
label: this.navRepositoriesText,
|
label: this.navRepositoriesText,
|
||||||
fn: function(){
|
fn: function(){
|
||||||
this.mainTabPanel.setActiveTab('repositories');
|
this.mainTabPanel.setActiveTab('repositories');
|
||||||
@@ -109,7 +109,7 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
|||||||
if ( state.user.type == 'xml' && state.user.name != 'anonymous' ){
|
if ( state.user.type == 'xml' && state.user.name != 'anonymous' ){
|
||||||
securitySection = {
|
securitySection = {
|
||||||
title: this.sectionSecurityText,
|
title: this.sectionSecurityText,
|
||||||
items: [{
|
links: [{
|
||||||
label: this.navChangePasswordText,
|
label: this.navChangePasswordText,
|
||||||
fn: function(){
|
fn: function(){
|
||||||
new Sonia.action.ChangePasswordWindow().show();
|
new Sonia.action.ChangePasswordWindow().show();
|
||||||
@@ -123,7 +123,7 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
|||||||
panel.addSections([{
|
panel.addSections([{
|
||||||
id: 'navConfig',
|
id: 'navConfig',
|
||||||
title: this.sectionConfigText,
|
title: this.sectionConfigText,
|
||||||
items: [{
|
links: [{
|
||||||
label: this.navGeneralConfigText,
|
label: this.navGeneralConfigText,
|
||||||
fn: function(){
|
fn: function(){
|
||||||
this.addTabPanel("scmConfig", "scmConfig", this.navGeneralConfigText);
|
this.addTabPanel("scmConfig", "scmConfig", this.navGeneralConfigText);
|
||||||
@@ -147,18 +147,18 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
|||||||
if ( securitySection == null ){
|
if ( securitySection == null ){
|
||||||
securitySection = {
|
securitySection = {
|
||||||
title: this.sectionSecurityText,
|
title: this.sectionSecurityText,
|
||||||
items: []
|
links: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
securitySection.items.push({
|
securitySection.links.push({
|
||||||
label: this.navUsersText,
|
label: this.navUsersText,
|
||||||
fn: function(){
|
fn: function(){
|
||||||
this.addTabPanel('users', 'userPanel', this.navUsersText);
|
this.addTabPanel('users', 'userPanel', this.navUsersText);
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
securitySection.items.push({
|
securitySection.links.push({
|
||||||
label: this.navGroupsText,
|
label: this.navGroupsText,
|
||||||
fn: function(){
|
fn: function(){
|
||||||
this.addTabPanel('groups', 'groupPanel', this.tabGroupsText);
|
this.addTabPanel('groups', 'groupPanel', this.tabGroupsText);
|
||||||
@@ -175,7 +175,7 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
|||||||
panel.addSection({
|
panel.addSection({
|
||||||
id: 'navLogin',
|
id: 'navLogin',
|
||||||
title: this.sectionLoginText,
|
title: this.sectionLoginText,
|
||||||
items: [{
|
links: [{
|
||||||
label: this.sectionLoginText,
|
label: this.sectionLoginText,
|
||||||
fn: this.login,
|
fn: this.login,
|
||||||
scope: this
|
scope: this
|
||||||
@@ -185,7 +185,7 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
|||||||
panel.addSection({
|
panel.addSection({
|
||||||
id: 'navLogout',
|
id: 'navLogout',
|
||||||
title: this.sectionLogoutText,
|
title: this.sectionLogoutText,
|
||||||
items: [{
|
links: [{
|
||||||
label: this.navLogoutText,
|
label: this.navLogoutText,
|
||||||
fn: this.logout,
|
fn: this.logout,
|
||||||
scope: this
|
scope: this
|
||||||
|
|||||||
Reference in New Issue
Block a user