2014-11-04 23:18:44 |
Gloria Gu |
description |
I am following the instruction regarding how to add in-line edit to the tables based on http://docs.openstack.org/developer/horizon/topics/tables.html
I used admin -> volumes
I updated following block to the volumes tab table: openstack_dashborad/dashobards/admin/volumes/volumes/tables.py
class UpdateRow(tables.Row):
ajax = True
def get_data(self, request, volume_id):
volume = cinder.volume_get(request, volume_id)
return volume
class UpdateCell(tables.UpdateAction):
def allowed(self, request, volume, cell):
return True
def update_cell(self, request, data, id,
cell_name, new_cell_value):
obj = data
setattr(obj, cell_name, new_cell_value)
value = getattr(obj, 'name', None)
return True
class VolumesTable(volumes_tables.VolumesTable):
"""
name = tables.Column("name",
verbose_name=_("Name"),
link="horizon:admin:volumes:volumes:detail")"""
name = tables.Column("name", verbose_name=_("Name"),
form_field=forms.CharField(
max_length=64, required=False),
update_action=UpdateCell)
......more code
I updated the following block to the volume types tab table: penstack_dashborad/dashobards/admin/volumes/volume_types/tables.py
class UpdateRow(tables.Row):
ajax = True
def get_data(self, request, volume_type_id):
volume_type = cinder.volume_type_get(request, volume_type_id)
return volume_type
class UpdateCell(tables.UpdateAction):
def allowed(self, request, volume_type, cell):
return True
def update_cell(self, request, data, volume_type_id,
cell_name, new_cell_value):
obj = data
setattr(obj, cell_name, new_cell_value)
value = getattr(obj, 'name', None)
return True
class VolumeTypesTable(tables.DataTable):
# name = tables.Column("name", verbose_name=_("Name"))
name = tables.Column("name", verbose_name=_("Name"),
form_field=forms.CharField(
max_length=64, required=False),
update_action=UpdateCell)
.....more code
I also add the similar code to snapshots table
The inline code for volumes it works fine. The inline code for volume_types seems to have problem.
examine the element noticed the following difference:
element for the name in volumes table
when not hover:
<div class="table_cell_action" style="display: none;"><button class="ajax-inline-edit"><span class="glyphicon glyphicon-pencil"></span></button></div>
when hover:
<div class="table_cell_action" style="display: block;"><button class="ajax-inline-edit"><span class="glyphicon glyphicon-pencil"></span></button></div>
element for the name in volume_types table is missing display:none as styling even both of volumes and volume_types using the same openstack_dashboard/static/dashboard/scss/_inline_edit.scss.
<div class="table_cell_action"><button class="ajax-inline-edit"><span class="glyphicon glyphicon-pencil"></span></button></div>
If I add that display:none or display:block into <div class="table_cell_action"> it seems to work for volume_types. However it sort of disables the volumes in-line-edit.
Looks like the in-line edit only allows the first tab's table in-line edit by default, it doesn't seem to allow in-line edit to wirk in multiple tables on different tabs |
I am following the instruction regarding how to add in-line edit to the tables based on http://docs.openstack.org/developer/horizon/topics/tables.html
I used admin -> volumes
I updated following block to the volumes tab table: openstack_dashborad/dashobards/admin/volumes/volumes/tables.py
class UpdateRow(tables.Row):
ajax = True
def get_data(self, request, volume_id):
volume = cinder.volume_get(request, volume_id)
return volume
class UpdateCell(tables.UpdateAction):
def allowed(self, request, volume, cell):
return True
def update_cell(self, request, data, id,
cell_name, new_cell_value):
obj = data
setattr(obj, cell_name, new_cell_value)
value = getattr(obj, 'name', None)
return True
class VolumesTable(volumes_tables.VolumesTable):
"""
name = tables.Column("name",
verbose_name=_("Name"),
link="horizon:admin:volumes:volumes:detail")"""
name = tables.Column("name", verbose_name=_("Name"),
form_field=forms.CharField(
max_length=64, required=False),
update_action=UpdateCell)
......more code
I updated the following block to the volume types tab table: openstack_dashborad/dashobards/admin/volumes/volume_types/tables.py
class UpdateRow(tables.Row):
ajax = True
def get_data(self, request, volume_type_id):
volume_type = cinder.volume_type_get(request, volume_type_id)
return volume_type
class UpdateCell(tables.UpdateAction):
def allowed(self, request, volume_type, cell):
return True
def update_cell(self, request, data, volume_type_id,
cell_name, new_cell_value):
obj = data
setattr(obj, cell_name, new_cell_value)
value = getattr(obj, 'name', None)
return True
class VolumeTypesTable(tables.DataTable):
# name = tables.Column("name", verbose_name=_("Name"))
name = tables.Column("name", verbose_name=_("Name"),
form_field=forms.CharField(
max_length=64, required=False),
update_action=UpdateCell)
.....more code
I also add the similar code to snapshots table
The inline code for volumes table it works fine. The inline code for volume_types table seems to have problem. the inline code for snapshots table doesn't work either.
examine the element noticed the following difference:
element for the name cell in volumes table
when not hover:
<div class="table_cell_action" style="display: none;"><button class="ajax-inline-edit"><span class="glyphicon glyphicon-pencil"></span></button></div>
when hover:
<div class="table_cell_action" style="display: block;"><button class="ajax-inline-edit"><span class="glyphicon glyphicon-pencil"></span></button></div>
element for the name cell in volume_types table is missing display:none as styling even both of volumes and volume_types using the same openstack_dashboard/static/dashboard/scss/_inline_edit.scss.
<div class="table_cell_action"><button class="ajax-inline-edit"><span class="glyphicon glyphicon-pencil"></span></button></div>
If I add that display:none or display:block into <div class="table_cell_action"> it seems to work for volume_types table. However it sort of disables the volumes in-line-edit.
Looks like the in-line edit only allows the first tab's table in-line edit by default, it doesn't seem to allow in-line edit to work in multiple tables on different tabs |
|