Skip to content

Commit

Permalink
Merge branch 'main' into fix_createBlobField
Browse files Browse the repository at this point in the history
  • Loading branch information
drfho authored Jul 13, 2023
2 parents 58f0270 + beefa09 commit c6296c1
Show file tree
Hide file tree
Showing 7 changed files with 214 additions and 153 deletions.
51 changes: 51 additions & 0 deletions Products/zms/conf/metacmd_manager/manage_css_classes/__init__.py
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"}
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 += '&nbsp;<button type="submit" name="btn" class="btn btn-secondary" value="BTN_CANCEL">%s</button>'%(self.getZMILangStr('BTN_CANCEL'))
html += '&nbsp;</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
73 changes: 43 additions & 30 deletions Products/zms/import/com.zms.search.content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,55 @@
<ZMSTextarea id_prefix="e">
<format><![CDATA[plain_html]]></format>
<text>
<lang id="ger"><![CDATA[<form class="search" method="get">
<lang id="ger"><![CDATA[<form class="search" method="get" xmlns:tal="http://xml.zope.org/namespaces/tal">
<tal:block tal:condition="python:request.get('searchform')">
<input tal:condition="python:request.get('searchform')" type="hidden" name="searchform" tal:attributes="value python:request.get('searchform')" />
<input tal:condition="python:request.get('lang')" type="hidden" name="lang" tal:attributes="value python:request.get('lang')" />
<input tal:condition="python:request.get('preview')" type="hidden" name="preview" tal:attributes="value python:request.get('preview')" />
<legend tal:content="python:here.getZMILangStr('SEARCH_HEADER')">Search header</legend>
<div class="form-group row">
<div class="col-md-12">
<div class="input-group">
<tal:block tal:content="structure python:here.getTextInput(fmName='searchform',elName='search',value=request.get('search',''))">the value</tal:block>
<div class="input-group-append">
<button type="submit" class="btn btn-primary"><i class="fas fa-search"></i></button>
<tal:block tal:condition="python:request.get('searchform',True)">
<input tal:condition="python:request.get('searchform')" type="hidden" name="searchform" tal:attributes="value python:request.get('searchform')" />
<input tal:condition="python:request.get('lang')" type="hidden" name="lang" tal:attributes="value python:request.get('lang')" />
<input tal:condition="python:request.get('preview')" type="hidden" name="preview" tal:attributes="value python:request.get('preview')" />
<legend tal:content="python:here.getZMILangStr('SEARCH_HEADER')">Search header</legend>
<div class="form-group">
<div class="col-md-12">
<div class="input-group">
<tal:block tal:content="structure python:here.getTextInput(fmName='searchform',elName='search',value=request.get('search',''))">the value</tal:block>
<span class="input-group-btn">
<button type="submit" class="btn btn-primary">
<i class="fa fa-search icon-search"></i>
</button>
</span>
</div>
</div>
</div>
</div><!-- .form-group -->
</div><!-- .form-group -->
<div class="form-group row" tal:condition="python:here.getPortalMaster() is not None or len(here.getPortalClients())>0">
<div class="control-label col-md-12" tal:define="home_id python:here.getHome().id">
<input type="hidden" name="home_id" tal:attributes="value python:request.get('home_id',home_id); data-value home_id">
<input type="checkbox" class="form-check-input" onchange="var $i=$('input[name=home_id]');$i.val(this.checked?$i.attr('data-value'):'');" tal:attributes="checked python:['','checked'][request.get('home_id',home_id)==home_id]">
<label class="form-check-label control-label">
<strong tal:content="home_id">the home-id</strong> (local)
</label>
</div>
</div><!-- .form-group -->
</tal:block>
<div id="search_results" class="form-group row" style="display:none">
<div class="col-md-12">
<h4 tal:content="python:here.getZMILangStr('SEARCH_HEADERRESULT')">Result</h4>
<div class="header row">
<div class="col-md-12">
<span class="small-head">
<i class="text-primary fas fa-spinner fa-spin"></i>
<tal:block tal:content="python:here.getZMILangStr('MSG_LOADING')">loading</tal:block>
</span>
</div>
</div><!-- .header.row -->
<div class="line row"></div><!-- .row -->
<div class="pull-right">
<ul class="pagination"></ul>
</div>
<div id="search_results" class="form-group" style="display:none">
<div class="col-md-12">
<h4 tal:content="python:here.getZMILangStr('SEARCH_HEADERRESULT')">
Result
</h4>
<div class="header row">
<div class="col-md-12">
<span class="small-head">
<span class="glyphicon glyphicon-refresh fas fa-spinner fa-spin" alt="Loading..."></span>
<tal:block tal:content="python:here.getZMILangStr('MSG_LOADING')">loading</tal:block>
</span>
</div>
</div><!-- .header.row -->
<div class="line row"></div><!-- .row -->
<div class="pull-right">
<ul class="pagination"></ul>
</div>
</div>
</div>
</div>
</form>
Expand Down
1 change: 1 addition & 0 deletions Products/zms/plugins/www/zmi.core.css
Original file line number Diff line number Diff line change
Expand Up @@ -1773,6 +1773,7 @@ table.table-sm tr.row_insert td .btn-add {
.zmi.repository_manager_main .tab-content.update_direction-Saving.auto_update-True.debug-1 #btn_save_to_repo {
color: #fff;
background-color: #4CAF50;
border-color: #28a745;
}
.zmi.repository_manager_main .tab-content.update_direction-Loading.auto_update-True.debug-1 #btn_load_from_repo:hover,
.zmi.repository_manager_main .tab-content.update_direction-Saving.auto_update-True.debug-1 #btn_save_to_repo:hover {
Expand Down
2 changes: 1 addition & 1 deletion Products/zms/zpt/ZMSMetamodelProvider/manage_main.zpt
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@
<td colspan="2" class="meta-id">
<tal:block tal:condition="python:metaObjPackage"
><i tal:condition="python:metaObj.get('acquired',None)" class="fas fa-share" title="acquired"></i>
<a tal:condition="python:metaObjPackage"
<a tal:condition="python:metaObjPackage" data-turbolinks="false"
tal:attributes="href python:'manage_bigpicture?lang=%s&id=%s'%(request['lang'],metaObjPackage); title python:'%s - Click for big picture...'%metaObjPackage" target="_blank"
><i class="fas fa-briefcase"></i></a>
&nbsp;
Expand Down
Loading

0 comments on commit c6296c1

Please sign in to comment.