mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-13 07:40:21 +01:00
improve repository permission grid
This commit is contained in:
@@ -49,6 +49,7 @@
|
||||
|
||||
<script type="text/javascript" src="resources/extjs/adapter/ext/ext-base.js"></script>
|
||||
<script type="text/javascript" src="resources/extjs/ext-all-debug.js"></script>
|
||||
<script type="text/javascript" src="resources/extjs/util/CheckColumn.js"></script>
|
||||
|
||||
<script type="text/javascript" src="resources/js/sonia.global.js"></script>
|
||||
<script type="text/javascript" src="resources/js/sonia.navigation.js"></script>
|
||||
|
||||
71
scm-webapp/src/main/webapp/resources/extjs/util/CheckColumn.js
vendored
Normal file
71
scm-webapp/src/main/webapp/resources/extjs/util/CheckColumn.js
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
/*!
|
||||
* Ext JS Library 3.3.1
|
||||
* Copyright(c) 2006-2010 Sencha Inc.
|
||||
* licensing@sencha.com
|
||||
* http://www.sencha.com/license
|
||||
*/
|
||||
Ext.ns('Ext.ux.grid');
|
||||
|
||||
/**
|
||||
* @class Ext.ux.grid.CheckColumn
|
||||
* @extends Ext.grid.Column
|
||||
* <p>A Column subclass which renders a checkbox in each column cell which toggles the truthiness of the associated data field on click.</p>
|
||||
* <p><b>Note. As of ExtJS 3.3 this no longer has to be configured as a plugin of the GridPanel.</b></p>
|
||||
* <p>Example usage:</p>
|
||||
* <pre><code>
|
||||
var cm = new Ext.grid.ColumnModel([{
|
||||
header: 'Foo',
|
||||
...
|
||||
},{
|
||||
xtype: 'checkcolumn',
|
||||
header: 'Indoor?',
|
||||
dataIndex: 'indoor',
|
||||
width: 55
|
||||
}
|
||||
]);
|
||||
|
||||
// create the grid
|
||||
var grid = new Ext.grid.EditorGridPanel({
|
||||
...
|
||||
colModel: cm,
|
||||
...
|
||||
});
|
||||
* </code></pre>
|
||||
* In addition to toggling a Boolean value within the record data, this
|
||||
* class toggles a css class between <tt>'x-grid3-check-col'</tt> and
|
||||
* <tt>'x-grid3-check-col-on'</tt> to alter the background image used for
|
||||
* a column.
|
||||
*/
|
||||
Ext.ux.grid.CheckColumn = Ext.extend(Ext.grid.Column, {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Process and refire events routed from the GridView's processEvent method.
|
||||
*/
|
||||
processEvent : function(name, e, grid, rowIndex, colIndex){
|
||||
if (name == 'mousedown') {
|
||||
var record = grid.store.getAt(rowIndex);
|
||||
record.set(this.dataIndex, !record.data[this.dataIndex]);
|
||||
return false; // Cancel row selection.
|
||||
} else {
|
||||
return Ext.grid.ActionColumn.superclass.processEvent.apply(this, arguments);
|
||||
}
|
||||
},
|
||||
|
||||
renderer : function(v, p, record){
|
||||
p.css += ' x-grid3-check-col-td';
|
||||
return String.format('<div class="x-grid3-check-col{0}"> </div>', v ? '-on' : '');
|
||||
},
|
||||
|
||||
// Deprecate use as a plugin. Remove in 4.0
|
||||
init: Ext.emptyFn
|
||||
});
|
||||
|
||||
// register ptype. Deprecate. Remove in 4.0
|
||||
Ext.preg('checkcolumn', Ext.ux.grid.CheckColumn);
|
||||
|
||||
// backwards compat. Remove in 4.0
|
||||
Ext.grid.CheckColumn = Ext.ux.grid.CheckColumn;
|
||||
|
||||
// register Column xtype
|
||||
Ext.grid.Column.types.checkcolumn = Ext.ux.grid.CheckColumn;
|
||||
@@ -226,7 +226,11 @@ Sonia.repository.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
||||
|
||||
this.permissionStore = new Ext.data.JsonStore({
|
||||
root: 'permissions',
|
||||
fields: [ 'name', 'type', 'groupPermission' ],
|
||||
fields: [
|
||||
{name: 'name'},
|
||||
{name: 'type'},
|
||||
{name: 'groupPermission', type: 'boolean'}
|
||||
],
|
||||
sortInfo: {
|
||||
field: 'name'
|
||||
}
|
||||
@@ -237,6 +241,12 @@ Sonia.repository.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
||||
sortable: true
|
||||
},
|
||||
columns: [{
|
||||
id: 'groupPermission',
|
||||
xtype: 'checkcolumn',
|
||||
header: 'Group Permission',
|
||||
dataIndex: 'groupPermission',
|
||||
width: 40
|
||||
},{
|
||||
id: 'name',
|
||||
header: 'Name',
|
||||
dataIndex: 'name',
|
||||
@@ -264,12 +274,6 @@ Sonia.repository.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
||||
]
|
||||
})
|
||||
})
|
||||
},{
|
||||
id: 'groupPermission',
|
||||
header: 'Group',
|
||||
dataIndex: 'groupPermission',
|
||||
width: 60,
|
||||
editor: new Ext.form.Checkbox()
|
||||
}]
|
||||
});
|
||||
|
||||
@@ -323,6 +327,7 @@ Sonia.repository.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
||||
xtype: 'editorgrid',
|
||||
title: 'Permissions',
|
||||
clicksToEdit: 1,
|
||||
autoExpandColumn: 'name',
|
||||
frame: true,
|
||||
width: '100%',
|
||||
autoHeight: true,
|
||||
|
||||
Reference in New Issue
Block a user