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 Nov 5, 2018
1 parent 6fa8018 commit 28bcf2a
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 30 deletions.
20 changes: 20 additions & 0 deletions library_sample_shared/migrations/0003_libraryprotocol_obsolete.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-10-31 14:43
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('library_sample_shared', '0002_libraryprotocol_status'),
]

operations = [
migrations.AddField(
model_name='libraryprotocol',
name='obsolete',
field=models.PositiveIntegerField(default=1, verbose_name='Obsolete'),
),
]
16 changes: 2 additions & 14 deletions static/main-hub/app/view/pooling/Pooling.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,8 @@ 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 Down
72 changes: 56 additions & 16 deletions static/main-hub/app/view/pooling/PoolingController.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Ext.define('MainHub.view.pooling.PoolingController', {
var grid = gridView.grid;
var customConfig = gridView.grid.initialConfig.customConfig;
var qcMenuOptions = [];


var menuItems = [
{
text: 'Select All',
Expand All @@ -64,7 +66,9 @@ Ext.define('MainHub.view.pooling.PoolingController', {
text: 'Edit comment',
margin: '5px 5px 0 5px',
handler: function (){
var self = this;

console.log(self);
console.log(parseInt(groupId))
var store = grid.getStore();
var comment = '';
var i = 0;
Expand All @@ -73,23 +77,28 @@ Ext.define('MainHub.view.pooling.PoolingController', {
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)
Ext.MessageBox.show({
title: 'Edit comment',
width:300,
buttons: Ext.MessageBox.OKCANCEL,
buttonText:{
ok: "Save",
cancel: "Don't save"
},
multiline: true,
value: comment,
fn : function(btn,text){
if(btn=='ok'){
self.editComment(self,store,parseInt(groupId),text)
//self.syncStore(store.getId());
}

}

});
}
}
];
Expand Down Expand Up @@ -209,6 +218,37 @@ Ext.define('MainHub.view.pooling.PoolingController', {
});
},

editComment: function(self,store,groupId,text){
Ext.Ajax.request({
url: Ext.String.format('api/pooling/{0}/edit_comment/', groupId),
method: 'POST',
scope: self,
params:{
data:Ext.JSON.encode({
newComment:text
})

},
success: function (response) {
var obj = Ext.JSON.decode(response.responseText);

if (obj.success) {
Ext.getStore('Pooling').reload();
new Noty({ text: 'New comment has been saved!' }).show();
}

else {
new Noty({ text: obj.message, type: 'error' }).show();
}
},

failure: function (response) {
new Noty({ text: response.statusText, type: 'error' }).show();
console.error(response);
}
});
},

toggleEditors: function (editor, context) {
var record = context.record;
if (
Expand Down

0 comments on commit 28bcf2a

Please sign in to comment.