-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix_createBlobField
- Loading branch information
Showing
7 changed files
with
214 additions
and
153 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
Products/zms/conf/metacmd_manager/manage_css_classes/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
class manage_css_classes: | ||
""" | ||
python-representation of manage_css_classes | ||
""" | ||
|
||
# Acquired | ||
acquired = 0 | ||
|
||
# Action | ||
action = "%smanage_executeMetacmd?id=manage_css_classes" | ||
|
||
# Description | ||
description = "" | ||
|
||
# Execution | ||
execution = 0 | ||
|
||
# Icon_clazz | ||
icon_clazz = "fab fa-css3 text-primary" | ||
|
||
# Id | ||
id = "manage_css_classes" | ||
|
||
# Meta_types | ||
meta_types = ["ZMSTextarea"] | ||
|
||
# Name | ||
name = "CSS Specials" | ||
|
||
# Nodes | ||
nodes = "{$}" | ||
|
||
# Package | ||
package = "" | ||
|
||
# Revision | ||
revision = "5.0.0" | ||
|
||
# Roles | ||
roles = ["ZMSAdministrator"] | ||
|
||
# Stereotype | ||
stereotype = "" | ||
|
||
# Title | ||
title = "Add special CSS class names to object's internal_dict" | ||
|
||
# Impl | ||
class Impl: | ||
manage_css_classes = {"id":"manage_css_classes" | ||
,"type":"External Method"} |
207 changes: 90 additions & 117 deletions
207
...port/manage_css_classes-1.0.0.metacmd.xml → .../manage_css_classes/manage_css_classes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,117 +1,90 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<list> | ||
<item type="dictionary"> | ||
<dictionary> | ||
<item key="data"><![CDATA[from Products.PythonScripts.standard import html_quote | ||
from Products.zms import standard | ||
# README ++++++++++++++++++++++++++++++++++++++ | ||
# This ZMS action adds a list of strings to the ZMS multidict attribute named | ||
# internal_dict. The list values are rendered into the body.zmi element as | ||
# additional CSS classes. This allows special GUI modifications of any | ||
# individual ZMS object # correspondting to the selected class values. | ||
# The example code uses the list of ZMS roles for specific class names. | ||
# You can change the code to user # an other name list fitting to your needs. | ||
# Hint: You can use the function get_css_classes() to add the css classes to | ||
# the third view templates (standard_html) | ||
# +++++++++++++++++++++++++++++++++++++++++++++ | ||
def get_css_classes(ob): | ||
internal_dict = ob.attr('internal_dict') | ||
css_classes = internal_dict.get('css_classes',[]) | ||
return (css_classes) | ||
def set_css_classes(ob,css_classes): | ||
internal_dict = ob.attr('internal_dict') | ||
internal_dict['css_classes'] = css_classes | ||
ob.setObjStateModified(ob.REQUEST) | ||
ob.setObjProperty('internal_dict',internal_dict) | ||
ob.onChangeObj(ob.REQUEST) | ||
# Workflow: Auto-Commit | ||
ob.commitObj(ob.REQUEST) | ||
# return ob.attr('internal_dict')['css_classes'] | ||
return True | ||
def manage_css_classes(self): | ||
request = self.REQUEST | ||
html = '' | ||
html += '<!DOCTYPE html>' | ||
html += '<html lang="en">' | ||
html += self.zmi_html_head(self,request) | ||
html += '<body class="%s">'%(' '.join(['zmi',request['lang'],'transition',self.meta_id])) | ||
html += self.zmi_body_header(self,request,options=[{'action':'#','label':'CSS Classes'}]) | ||
html += '<div id="zmi-tab">' | ||
html += self.zmi_breadcrumbs(self,request) | ||
html += '<form class="form-horizontal" method="post" enctype="multipart/form-data">' | ||
html += '<input type="hidden" name="form_id" value="manage_css_classes"/>' | ||
html += '<input type="hidden" name="lang" value="%s"/>'%request['lang'] | ||
html += '<legend>Add Special CSS Classes:</legend>' | ||
# --- Insert css_classes. | ||
# --------------------------------- | ||
if request.form.get('btn')==self.getZMILangStr('BTN_INSERT'): | ||
message = [] | ||
css_classes = request.get('css_classes',[]) | ||
if css_classes: | ||
set_css_classes(self,css_classes) | ||
message.append('CSS classes added: %s'%(css_classes)) | ||
else: | ||
set_css_classes(self,[]) | ||
message.append('No CSS classes added, existing CSS classes removed') | ||
request.response.redirect(standard.url_append_params('%s/manage_main'%self.absolute_url(),{'lang':request['lang'],'manage_tabs_message':'<br/>'.join(message)})) | ||
# --- Display initial insert form. | ||
# --------------------------------- | ||
else: | ||
# GENERATE CSS LIST (Example Code) | ||
css_classes = self.getRootElement().getSecurityRoles().keys() | ||
css_classes.extend(['ZMSAdministrator','ZMSEditor','ZMSAuthor','ZMSSubscriber','ZMSUserAdministrator']) | ||
css_classes = [[str(r)+'_special',str(r)+'_special'] for x in css_classes] | ||
# /GENERATE CSS LIST | ||
html += '<div class="form-group row">' | ||
html += '<div class="col-sm-12">' | ||
html += self.zmi_input_multiselect(self,name='css_classes',value=get_css_classes(self),lang_str='CSS Classes',options=css_classes) | ||
html += '</div>' | ||
html += '</div><!-- .form-group -->' | ||
html += '<div class="form-row">' | ||
html += '<div class="controls save">' | ||
html += '<button type="submit" name="btn" class="btn btn-primary" value="%s">%s</button> '%(self.getZMILangStr('BTN_INSERT'),self.getZMILangStr('BTN_INSERT')) | ||
html += '<button type="submit" name="btn" class="btn btn-secondary" value="%s">%s</button> '%(self.getZMILangStr('BTN_CANCEL'),self.getZMILangStr('BTN_CANCEL')) | ||
html += '</div><!-- .controls.save -->' | ||
html += '</div><!-- .form-group -->' | ||
# --------------------------------- | ||
html += '</form><!-- .form-horizontal -->' | ||
html += '</div><!-- #zmi-tab -->' | ||
html += self.zmi_body_footer(self,request) | ||
html += '</body>' | ||
html += '</html>' | ||
return html]]> | ||
</item> | ||
<item key="description"></item> | ||
<item key="execution" type="int">0</item> | ||
<item key="icon_clazz"><![CDATA[icon-css3 text-primary]]></item> | ||
<item key="id"><![CDATA[manage_css_classes]]></item> | ||
<item key="meta_type"><![CDATA[External Method]]></item> | ||
<item key="meta_types" type="list"> | ||
<list> | ||
<item><![CDATA[ZMSTextarea]]></item> | ||
</list> | ||
</item> | ||
<item key="name"><![CDATA[CSS Specials]]></item> | ||
<item key="revision"><![CDATA[1.0.0]]></item> | ||
<item key="roles" type="list"> | ||
<list> | ||
<item><![CDATA[ZMSAdministrator]]></item> | ||
</list> | ||
</item> | ||
<item key="title"><![CDATA[Add special CSS classes]]></item> | ||
</dictionary> | ||
</item> | ||
</list> | ||
# README ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
# This ZMS action adds a list of strings to the ZMS multidict attribute named | ||
# internal_dict. The list values may be rendered into element the elements html | ||
# output as additional CSS classes: | ||
# ----------------------------------------------------------------------------------- | ||
# tal:attributes="class python:' '.join(zmscontext.attr('internal_dict').get('css_classes',[]))" | ||
# ----------------------------------------------------------------------------------- | ||
# This allows special GUI modifications of any individual ZMS object corresponding | ||
# to the selected class values. The example code uses the list of ZMS roles for | ||
# specific class names. You can change the code to other name lists fitting to your needs. | ||
# Hint: You can use the function get_css_classes() to add the css classes to | ||
# the third view templates (standard_html) | ||
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
|
||
def get_css_classes(ob): | ||
internal_dict = ob.attr('internal_dict') | ||
css_classes = internal_dict.get('css_classes',[]) | ||
return (css_classes) | ||
|
||
def set_css_classes(ob,css_classes): | ||
internal_dict = ob.attr('internal_dict') | ||
internal_dict['css_classes'] = css_classes | ||
ob.setObjStateModified(ob.REQUEST) | ||
ob.setObjProperty('internal_dict',internal_dict) | ||
ob.onChangeObj(ob.REQUEST) | ||
# Workflow: Auto-Commit | ||
ob.commitObj(ob.REQUEST) | ||
# return ob.attr('internal_dict')['css_classes'] | ||
return True | ||
|
||
|
||
def manage_css_classes(self): | ||
request = self.REQUEST | ||
html = '' | ||
html += '<!DOCTYPE html>' | ||
html += '<html lang="en">' | ||
html += self.zmi_html_head(self,request) | ||
html += '<body class="%s">'%(' '.join(['zmi',request['lang'],'transition',self.meta_id])) | ||
html += self.zmi_body_header(self,request,options=[{'action':'#','label':'CSS Classes'}]) | ||
html += '<div id="zmi-tab">' | ||
html += self.zmi_breadcrumbs(self,request) | ||
html += '<form class="form-horizontal card" method="post" enctype="multipart/form-data">' | ||
html += '<input type="hidden" name="form_id" value="manage_css_classes"/>' | ||
html += '<input type="hidden" name="lang" value="%s"/>'%request['lang'] | ||
html += '<legend>Add Special CSS Classes:</legend>' | ||
|
||
# --- Insert css_classes. | ||
# --------------------------------- | ||
if request.form.get('btn')=='BTN_INSERT': | ||
message = [] | ||
css_classes = request.get('css_classes',[]) | ||
if css_classes: | ||
set_css_classes(self,css_classes) | ||
message.append('CSS classes added: %s'%(css_classes)) | ||
else: | ||
set_css_classes(self,[]) | ||
message.append('No CSS classes added, existing CSS classes removed') | ||
request.response.redirect(self.url_append_params('%s/manage_main'%self.absolute_url(),{'lang':request['lang'],'manage_tabs_message':'<br/>'.join(message)})) | ||
|
||
# --- Display initial insert form. | ||
# --------------------------------- | ||
else: | ||
|
||
# GENERATE CSS LIST (Example Code) | ||
css_classes = list(self.getRootElement().getSecurityRoles().keys()) | ||
css_classes.extend(['ZMSAdministrator','ZMSEditor','ZMSAuthor','ZMSSubscriber','ZMSUserAdministrator']) | ||
css_classes = map(lambda r: [str(r)+'_special',str(r)+'_special'],css_classes) | ||
# /GENERATE CSS LIST | ||
|
||
html += '<div class="card-body form-group row">' | ||
html += '<div class="col-sm-12">' | ||
html += self.zmi_input_multiselect(self,name='css_classes',value=get_css_classes(self),lang_str='CSS Classes',options=css_classes) | ||
html += '</div>' | ||
html += '</div><!-- .form-group -->' | ||
html += '<div class="form-group row">' | ||
html += '<div class="controls save">' | ||
html += '<button type="submit" name="btn" class="btn btn-primary" value="BTN_INSERT">%s</button>'%(self.getZMILangStr('BTN_INSERT')) | ||
html += ' <button type="submit" name="btn" class="btn btn-secondary" value="BTN_CANCEL">%s</button>'%(self.getZMILangStr('BTN_CANCEL')) | ||
html += ' </div>' | ||
html += '</div><!-- .form-group -->' | ||
|
||
# --------------------------------- | ||
|
||
html += '</form><!-- .form-horizontal -->' | ||
html += '</div><!-- #zmi-tab -->' | ||
html += self.zmi_body_footer(self,request) | ||
html += '</body>' | ||
html += '</html>' | ||
|
||
return html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.