Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/CanvasIFrame/pack.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


$packageID = "BuildingBlock_CanvasIFrame";
$packageLabel = "Canvas IFrame";
$packageLabel = "BuildingBlocks: Canvas IFrame";
$supportedVersionRegex = '(9|8|7)\\..*$';
/******************************/

Expand Down
2 changes: 1 addition & 1 deletion packages/ContextualIFrameDashlet/pack.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


$packageID = "BuildingBlock_ContextualIFrameDashlet";
$packageLabel = "Contextual iFrame Dashlet package";
$packageLabel = "BuildingBlocks: Contextual iFrame Dashlet package";
$supportedVersionRegex = '(9|8|7)\\..*$';
$acceptableSugarFlavors = array('PRO','ENT','ULT');
$description = 'Package for a configurable contextual iFrame Sugar Dashlet';
Expand Down
2 changes: 1 addition & 1 deletion packages/CssLoader/pack.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


$packageID = "BuildingBlock_CssLoader";
$packageLabel = "CssLoader";
$packageLabel = "BuildingBlocks: CssLoader";
$supportedVersionRegex = '(9|8|7)\\..*$';
$acceptableSugarFlavors = array('PRO','ENT','ULT');
$description = 'Loading custom CSS into Sugar made easy';
Expand Down
93 changes: 93 additions & 0 deletions packages/CustomHighlightField/pack.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/usr/bin/env php
<?php
// Copyright 2018 SugarCRM Inc. Licensed by SugarCRM under the Apache 2.0 license.


$packageID = "BuildingBlock_CustomHighlightField";
$packageLabel = "BuildingBlocks: Custom Field Highlightedfield";
$supportedVersionRegex = '(26|25|14)\\..*$';
$acceptableSugarFlavors = array('ENT');
$description = 'New field type called Highlightfield which changes background depending on the value.';
/******************************/

if (empty($argv[1])) {
if (file_exists("version")) {
$version = file_get_contents("version");
}
} else {
$version = $argv[1];
}

if (empty($version)){
die("Use $argv[0] [version]\n");
}

$id = "{$packageID}-{$version}";

$directory = "releases";
if(!is_dir($directory)){
mkdir($directory);
}

$zipFile = $directory . "/sugarcrm-{$id}.zip";


if (file_exists($zipFile)) {
die("Error: Release $zipFile already exists, so a new zip was not created. To generate a new zip, either delete the"
. " existing zip file or update the version number in the version file AND then run the script to build the"
. " module again. \n");
}

$manifest = array(
'id' => $packageID,
'name' => $packageLabel,
'description' => $description,
'version' => $version,
'author' => 'SugarCRM, Inc.',
'is_uninstallable' => 'true',
'published_date' => date("Y-m-d H:i:s"),
'type' => 'module',
'acceptable_sugar_versions' => array(
'exact_matches' => array(
),
'regex_matches' => array(
$supportedVersionRegex,
),
),
'acceptable_sugar_flavors' => $acceptableSugarFlavors,
);

$installdefs = array(
'beans' => array (),
'id' => $packageID
);

echo "Creating {$zipFile} ... \n";
$zip = new ZipArchive();
$zip->open($zipFile, ZipArchive::CREATE);
$basePath = realpath('src/');
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($basePath, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($files as $name => $file) {
if ($file->isFile()) {
$fileReal = $file->getRealPath();
$fileRelative = 'src' . str_replace($basePath, '', $fileReal);
echo " [*] $fileRelative \n";
$zip->addFile($fileReal, $fileRelative);
$installdefs['copy'][] = array(
'from' => '<basepath>/' . $fileRelative,
'to' => preg_replace('/^src[\/\\\](.*)/', '$1', $fileRelative),
);
}
}
$manifestContent = sprintf(
"<?php\n\$manifest = %s;\n\$installdefs = %s;\n",
var_export($manifest, true),
var_export($installdefs, true)
);
$zip->addFromString('manifest.php', $manifestContent);
$zip->close();
echo "Done creating {$zipFile}\n\n";
exit(0);
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

$app_strings['LBL_HIGHLIGHTFIELD_OPERATOR_CONTAINS'] = 'contains';
$app_strings['LBL_HIGHLIGHTFIELD_OPERATOR_NOT_CONTAINS'] = 'does not contain';
$app_strings['LBL_HIGHLIGHTFIELD_OPERATOR_STARTS_WITH'] = 'starts with';

$app_list_strings['highlightColors'] = array(
'#0000FF' => 'Blue',
'#00ffff' => 'Aqua',
'#FF00FF' => 'Fuchsia',
'#808080' => 'Gray',
'#ffff00' => 'Olive',
'#000000' => 'Black',
'#800000' => 'Maroon',
'#ff0000' => 'Red',
'#ffA500' => 'Orange',
'#ffff00' => 'Yellow',
'#800080' => 'Purple',
'#ffffff' => 'White',
'#00ff00' => 'Lime',
'#008000' => 'Green',
'#008080' => 'Teal',
'#c0c0c0' => 'Silver',
'#000080' => 'Navy'
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

$mod_strings['LBL_HIGHLIGHTFIELD'] = 'Highlighted Text';
$mod_strings['LBL_HIGHLIGHTFIELD_FORMAT_HELP'] = '';

$mod_strings['LBL_HIGHLIGHTFIELD_BACKCOLOR'] = 'Background Color';
$mod_strings['LBL_HIGHLIGHTFIELD_TEXTCOLOR'] = 'Text Color';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

$mod_strings['fieldTypes']['Highlightfield'] = 'Highlighted Text';
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* @class View.Fields.Base.Highlightfield
* @alias SUGAR.App.view.fields.Highlightfield
* @extends View.Fields.Base.BaseField
*/
({
extendsFrom: 'BaseField',

/**
* Called when initializing the field
* @param options
*/
initialize: function(options) {
this._super('initialize', [options]);
},

/**
* Called when rendering the field
* @private
*/
_render: function() {
this._super('_render');
},

/**
* Called when formatting the value for display
* @param value
*/
format: function(value) {
return this._super('format', [value]);
},

/**
* Called when unformatting the value for storage
* @param value
*/
unformat: function(value) {
return this._super('unformat', [value]);
}
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{!
The data for field colors are passed into the handlebars template through the def array. For this example, the def.backcolor and def.textcolor properties. These indexes are defined in:
./custom/modules/DynamicFields/templates/Fields/TemplateHighlightfield.php
}}
{{#if value}}
<div class="ellipsis_inline" data-bs-placement="bottom"{{#if dir}} dir="{{dir}}"{{/if}} title="{{value}}" style="background:{{def.backcolor}}; color:{{def.textcolor}}">
{{value}}
</div>
{{/if}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{!
We have not made any edits to this file that differ from stock, however,
we could add styling here just as we did for the detail and list templates.
}}

<input
type="text"
name="{{name}}"
value="{{value}}"
{{#if def.len}} maxlength="{{def.len}}"{{/if}}
{{#if def.tabindex}} tabindex="{{def.tabindex}}"{{/if}}
{{#if def.placeholder}} placeholder="{{str def.placeholder this.model.module}}"{{/if}}
class="inherit-width">
{{#unless hideHelp}}
{{#if def.help}}
<p class="help-block">{{str def.help module}}</p>
{{/if}}
{{/unless}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{!
The data for field colors are passed into the handlebars template through the def array. Our case
being the def.backcolor and def.textcolor properties. These indexes are defined in:
./custom/modules/DynamicFields/templates/Fields/TemplateHighlightfield.php
}}

{{#if ellipsis}}
<div class="ellipsis_inline" data-bs-placement="bottom"{{#if dir}} dir="{{dir}}"{{/if}} title="{{#unless value}}{{#if def.placeholder}}{{str def.placeholder this.model.module}}{{/if}}{{/unless}}{{value}}"
style="background:{{def.backcolor}}; color:{{def.textcolor}}">
{{/if}}
{{#if href}}<a href="{{#if def.events}}javascript:void(0);{{else}}{{href}}{{/if}}">{{value}}</a>{{else}}{{value}}{{/if~}}
{{#if ellipsis}}
</div>
{{/if~}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

require 'clients/base/filters/operators/operators.php';

$viewdefs['base']['filter']['operators']['Highlightfield'] = array(
'$contains' => 'LBL_HIGHLIGHTFIELD_OPERATOR_CONTAINS',
'$not_contains' => 'LBL_HIGHLIGHTFIELD_OPERATOR_NOT_CONTAINS',
'$starts' => 'LBL_HIGHLIGHTFIELD_OPERATOR_STARTS_WITH',
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

require_once 'include/SugarFields/Fields/Base/SugarFieldBase.php';
require_once 'data/SugarBean.php';

class SugarFieldHighlightfield extends SugarFieldBase
{
//this function is called to format the field before saving. For example we could put code in here
// to check spelling or to change the case of all the letters
public function save($bean, $params, $field, $properties, $prefix = '')
{
$GLOBALS['log']->debug("SugarFieldHighlightfield::save() function called.");
parent::save($bean, $params, $field, $properties, $prefix);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

require_once 'include/generic/SugarWidgets/SugarWidgetFieldvarchar.php';

class SugarWidgetFieldHighlightfield extends SugarWidgetFieldVarchar
{
function SugarWidgetFieldText(&$layout_manager)
{
parent::SugarWidgetFieldVarchar($layout_manager);
}

function queryFilterEquals($layout_def)
{
return $this->reporter->db->convert($this->_get_column_select($layout_def), "text2char") .
" = " . $this->reporter->db->quoted($layout_def['input_name0']);
}

function queryFilterNot_Equals_Str($layout_def)
{
$column = $this->_get_column_select($layout_def);
return "($column IS NULL OR " . $this->reporter->db->convert($column, "text2char") . " != " .
$this->reporter->db->quoted($layout_def['input_name0']) . ")";
}

function queryFilterNot_Empty($layout_def)
{
$column = $this->_get_column_select($layout_def);
return "($column IS NOT NULL AND " . $this->reporter->db->convert($column, "length") . " > 0)";
}

function queryFilterEmpty($layout_def)
{
$column = $this->_get_column_select($layout_def);
return "($column IS NULL OR " . $this->reporter->db->convert($column, "length") . " = 0)";
}

function displayList($layout_def)
{
return nl2br(parent::displayListPlain($layout_def));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

require_once 'custom/modules/DynamicFields/templates/Fields/TemplateHighlightfield.php';

/**
* Implement get_body function to correctly populate the template for the ModuleBuilder/Studio
* Add field page.
*
* @param Sugar_Smarty $ss
* @param array $vardef
*
*/
function get_body(&$ss, $vardef)
{
global $app_list_strings, $mod_strings;
$vars = $ss->get_template_vars();
$fields = $vars['module']->mbvardefs->vardefs['fields'];
$fieldOptions = array();
foreach ($fields as $id => $def) {
$fieldOptions[$id] = $def['name'];
}
$ss->assign('fieldOpts', $fieldOptions);

//If there are no colors defined, use black text on
// a white background
if (isset($vardef['backcolor'])) {
$backcolor = $vardef['backcolor'];
} else {
$backcolor = '#ffffff';
}
if (isset($vardef['textcolor'])) {
$textcolor = $vardef['textcolor'];
} else {
$textcolor = '#000000';
}
$ss->assign('BACKCOLOR', $backcolor);
$ss->assign('TEXTCOLOR', $textcolor);

$colorArray = $app_list_strings['highlightColors'];
asort($colorArray);

$ss->assign('highlightColors', $colorArray);
$ss->assign('textColors', $colorArray);

$ss->assign('BACKCOLORNAME', $app_list_strings['highlightColors'][$backcolor]);
$ss->assign('TEXTCOLORNAME', $app_list_strings['highlightColors'][$textcolor]);

return $ss->fetch('custom/modules/DynamicFields/templates/Fields/Forms/Highlightfield.tpl');
}
Loading