Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Commit

Permalink
show all
Browse files Browse the repository at this point in the history
  • Loading branch information
risufaj committed Oct 24, 2018
1 parent a134f3d commit 9ae5454
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 4 deletions.
1 change: 1 addition & 0 deletions index_generator/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Pool(DateTimeMixin):
Library, related_name='pool', blank=True)
samples = models.ManyToManyField(
Sample, related_name='pool', blank=True)
comment = models.TextField(verbose_name='Comment', blank=True)

# def get_size(self):
# size = 0
Expand Down
2 changes: 2 additions & 0 deletions pooling/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class Pooling(DateTimeMixin):
blank=True
)

comment = models.TextField(verbose_name='Comment',blank=True)

class Meta:
verbose_name = 'Pooling'
verbose_name_plural = 'Pooling'
Expand Down
9 changes: 8 additions & 1 deletion pooling/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,11 @@ class PoolSerializer(ModelSerializer):

libraries = SerializerMethodField()
samples = SerializerMethodField()
comment = SerializerMethodField()

class Meta:
model = Pool
fields = ('pool', 'pool_name', 'pool_size', 'libraries', 'samples',)
fields = ('pool', 'pool_name', 'pool_size', 'libraries', 'samples','comment',)

def get_pool(self, obj):
return obj.pk
Expand All @@ -198,6 +199,10 @@ def get_samples(self, obj):
obj.samples, many=True, context=self.context)
return serializer.data

def get_comment(self,obj):
return obj.comment


def to_representation(self, instance):
data = super().to_representation(instance)
result = []
Expand All @@ -215,6 +220,8 @@ def to_representation(self, instance):
x['sequencing_depth'] /
instance.total_sequencing_depth * 100
)),

'comment': data['comment']
}, **x},
data.pop(type),
)))
Expand Down
4 changes: 4 additions & 0 deletions static/main-hub/app/model/pooling/Pooling.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ Ext.define('MainHub.model.pooling.Pooling', {
name: 'quality_check',
type: 'string',
allowNull: true
},
{
name: 'comment',
type: 'string'
}
]
});
21 changes: 19 additions & 2 deletions static/main-hub/app/view/pooling/Pooling.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,20 @@ Ext.define('MainHub.view.pooling.Pooling', {
tooltip: '% library in Pool',
dataIndex: 'percentage_library',
width: 55
}
},
{
text: 'Comments',
tooltip: 'Comments (facility)',
dataIndex: 'comment',
width: 150,
editor: {
xtype: 'textfield'
},
renderer: function (value, meta) {
meta.tdAttr = 'data-qtip="' + value + '"';
return value;
}
}
],

features: [{
Expand All @@ -162,7 +175,7 @@ Ext.define('MainHub.view.pooling.Pooling', {
groupHeaderTpl: [
'<strong class="{children:this.getHeaderClass}">' +
'{children:this.getName} | Pool Size: {children:this.getRealPoolSize} M reads ' +
'{children:this.getPoolSize}' +
'{children:this.getPoolSize}| Comment: {children:this.getComment} ' +
'</strong>',
{
getHeaderClass: function (children) {
Expand All @@ -181,6 +194,10 @@ Ext.define('MainHub.view.pooling.Pooling', {

return cls;
},
getComment: function(children){
return children[0].get('comment')

},
getName: function (children) {
return children[0].get('pool_name');
},
Expand Down
153 changes: 152 additions & 1 deletion static/main-hub/app/view/pooling/PoolingController.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Ext.define('MainHub.view.pooling.PoolingController', {
resize: 'resize',
boxready: 'addToolbarButtons',
itemcontextmenu: 'showMenu',
groupcontextmenu: 'showGroupMenu',
groupcontextmenu: 'showPoolingGroupMenu',
beforeEdit: 'toggleEditors',
edit: 'editRecord'
},
Expand All @@ -40,6 +40,157 @@ Ext.define('MainHub.view.pooling.PoolingController', {
}
},

showPoolingGroupMenu: function (gridView, node, groupId, e) {
var self = this;
var grid = gridView.grid;
var customConfig = gridView.grid.initialConfig.customConfig;
var qcMenuOptions = [];
var menuItems = [
{
text: 'Select All',
margin: '5px 5px 0 5px',
handler: function () {
self.selectUnselectAll(grid, parseInt(groupId), true);
}
},
{
text: 'Unselect All',
margin: 5,
handler: function () {
self.selectUnselectAll(grid, parseInt(groupId), false);
}
},
{
text: 'Edit comment',
margin: '5px 5px 0 5px',
handler: function (){
var self = this;
var store = grid.getStore();
var comment = '';
var i = 0;
store.each(function (item) {

if (item.get(store.groupField) === parseInt(groupId)) {

comment = item.get('comment')
console.log(comment)
}
});
var editcomment = {
xtype: 'container',
layout: 'hbox',
items: [{
xtype: 'textfield',
width: 100
},
{
xtype: 'button',
text: 'Click Me'
}]
};

menuItems.push(editcomment)
}
}
];

if (customConfig && customConfig.qualityCheckMenuOptions) {
qcMenuOptions = customConfig.qualityCheckMenuOptions;
}

if (
qcMenuOptions.length > 0 &&
self._getSelectedRecords(grid.getStore(), parseInt(groupId)).length > 0
) {
var qcMenu = {
xtype: 'container',
items: [
{
xtype: 'container',
html: 'Quality Check: Selected',
margin: '10px 5px 5px 5px',
style: {
color: '#000'
}
},
{
xtype: 'container',
margin: 5,
layout: {
type: 'hbox',
pack: 'center',
align: 'middle'
},
defaults: {
xtype: 'button',
scale: 'medium',
margin: '5px 10px 10px'
},
items: []
}
]
};

if (qcMenuOptions.indexOf('passed') !== -1) {
qcMenu.items[1].items.push({
ui: 'menu-button-green',
tooltip: 'passed',
iconCls: 'fa fa-lg fa-check',
handler: function () {
self.qualityCheckSelected(grid, parseInt(groupId), 'passed');
this.up('menu').hide();
}
});
}

if (qcMenuOptions.indexOf('completed') !== -1) {
qcMenu.items[1].items.push({
ui: 'menu-button-green',
tooltip: 'completed',
iconCls: 'fa fa-lg fa-check',
handler: function () {
self.qualityCheckSelected(grid, parseInt(groupId), 'completed');
this.up('menu').hide();
}
});
}

if (qcMenuOptions.indexOf('compromised') !== -1) {
qcMenu.items[1].items.push({
ui: 'menu-button-yellow',
tooltip: 'compromised',
iconCls: 'fa fa-lg fa-exclamation-triangle',
handler: function () {
self.qualityCheckSelected(grid, parseInt(groupId), 'compromised');
this.up('menu').hide();
}
});
}

if (qcMenuOptions.indexOf('failed') !== -1) {
qcMenu.items[1].items.push({
ui: 'menu-button-red',
tooltip: 'failed',
iconCls: 'fa fa-lg fa-times',
handler: function () {
self.qualityCheckSelected(grid, parseInt(groupId), 'failed');
this.up('menu').hide();
}
});
}

menuItems.push('-');
menuItems.push(qcMenu);
}

e.stopEvent();
Ext.create('Ext.menu.Menu', {
plain: true,
items: menuItems
}).showAt(e.getXY());
},


addToolbarButtons: function (grid) {
var toolbar = grid.down('toolbar[dock="bottom"]');

Expand Down

0 comments on commit 9ae5454

Please sign in to comment.