Added validation rules resolve gh-254. Removed empty sql files. Improved the field area.
This commit is contained in:
@ -278,12 +278,12 @@ function checkFunctionName(functioName) {
|
||||
// now start search for where the function is used
|
||||
usedin(result.name, ide);
|
||||
} else if(result.message){
|
||||
// show notice that functioName is not okay
|
||||
// show notice that functionName is not okay
|
||||
jQuery.UIkit.notify({message: result.message, timeout: 5000, status: result.status, pos: 'top-right'});
|
||||
jQuery('#jform_function_name').val('');
|
||||
} else {
|
||||
// set an error that message was not send
|
||||
jQuery.UIkit.notify({message: 'Function name already taken, please try again.', timeout: 5000, status: 'danger', pos: 'top-right'});
|
||||
jQuery.UIkit.notify({message: Joomla.JText._('COM_COMPONENTBUILDER_FUNCTION_NAME_ALREADY_TAKEN_PLEASE_TRY_AGAIN'), timeout: 5000, status: 'danger', pos: 'top-right'});
|
||||
jQuery('#jform_function_name').val('');
|
||||
}
|
||||
// set custom code placeholder
|
||||
@ -291,7 +291,7 @@ function checkFunctionName(functioName) {
|
||||
});
|
||||
} else {
|
||||
// set an error that message was not send
|
||||
jQuery.UIkit.notify({message: 'You must add an unique function name.', timeout: 5000, status: 'danger', pos: 'top-right'});
|
||||
jQuery.UIkit.notify({message: Joomla.JText._('COM_COMPONENTBUILDER_YOU_MUST_ADD_AN_UNIQUE_FUNCTION_NAME'), timeout: 5000, status: 'danger', pos: 'top-right'});
|
||||
jQuery('#jform_function_name').val('');
|
||||
// set custom code placeholder
|
||||
setCustomCodePlaceholder();
|
||||
|
@ -514,6 +514,8 @@ jQuery(document).ready(function()
|
||||
{
|
||||
// get the linked details
|
||||
getLinked();
|
||||
// get the validation rules
|
||||
getValidationRulesTable();
|
||||
});
|
||||
|
||||
function getLinked_server(type){
|
||||
@ -562,4 +564,26 @@ function getFieldOptions(id,setValue){
|
||||
jQuery('.helpNote').append('<div id="help" style="margin: 10px;">'+result.description+'<br />'+result.values_description+'</div>');
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function getValidationRulesTable_server(){
|
||||
var getUrl = "index.php?option=com_componentbuilder&task=ajax.getValidationRulesTable&format=json";
|
||||
if(token.length > 0){
|
||||
var request = 'token='+token+'&id=1';
|
||||
}
|
||||
return jQuery.ajax({
|
||||
type: 'GET',
|
||||
url: getUrl,
|
||||
dataType: 'jsonp',
|
||||
data: request,
|
||||
jsonp: 'callback'
|
||||
});
|
||||
}
|
||||
|
||||
function getValidationRulesTable(){
|
||||
getValidationRulesTable_server().done(function(result) {
|
||||
if(result){
|
||||
jQuery('#display_validation_rules').html(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
109
admin/models/forms/validation_rule.js
Normal file
109
admin/models/forms/validation_rule.js
Normal file
@ -0,0 +1,109 @@
|
||||
/*--------------------------------------------------------------------------------------------------------| www.vdm.io |------/
|
||||
__ __ _ _____ _ _ __ __ _ _ _
|
||||
\ \ / / | | | __ \ | | | | | \/ | | | | | | |
|
||||
\ \ / /_ _ ___| |_ | | | | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ | \ / | ___| |_| |__ ___ __| |
|
||||
\ \/ / _` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| '_ \ / _ \ / _` |
|
||||
\ / (_| \__ \ |_ | |__| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | | | | __/ |_| | | | (_) | (_| |
|
||||
\/ \__,_|___/\__| |_____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| |_| |_|\___|\__|_| |_|\___/ \__,_|
|
||||
| |
|
||||
|_|
|
||||
/-------------------------------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 2.7.x
|
||||
@created 30th April, 2015
|
||||
@package Component Builder
|
||||
@subpackage validation_rule.js
|
||||
@author Llewellyn van der Merwe <http://joomlacomponentbuilder.com>
|
||||
@github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||
@copyright Copyright (C) 2015. All Rights Reserved
|
||||
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
Builds Complex Joomla Components
|
||||
|
||||
/-----------------------------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
|
||||
jQuery(document).ready(function()
|
||||
{
|
||||
// get the rule name
|
||||
var ruleName = jQuery('#jform_name').val();
|
||||
// check if this rule name is taken
|
||||
checkRuleName(ruleName);
|
||||
|
||||
// get type value
|
||||
var rulefilename = jQuery("#jform_inherit option:selected").val();
|
||||
if(jQuery('#jform_php').length == 0) {
|
||||
getExistingValidationRuleCode(rulefilename);
|
||||
}
|
||||
|
||||
// load the used in div
|
||||
// jQuery('#usedin').show();
|
||||
});
|
||||
|
||||
function getExistingValidationRuleCode_server(rulefilename){
|
||||
var getUrl = "index.php?option=com_componentbuilder&task=ajax.getExistingValidationRuleCode&format=json";
|
||||
if(token.length > 0 && rulefilename.length > 0){
|
||||
var request = 'token='+token+'&name='+rulefilename;
|
||||
}
|
||||
return jQuery.ajax({
|
||||
type: 'GET',
|
||||
url: getUrl,
|
||||
dataType: 'jsonp',
|
||||
data: request,
|
||||
jsonp: 'callback'
|
||||
});
|
||||
}
|
||||
|
||||
function getExistingValidationRuleCode(rulefilename,setValue){
|
||||
getExistingValidationRuleCode_server(rulefilename).done(function(result) {
|
||||
if(result.values){
|
||||
jQuery('textarea#jform_php').val(result.values);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function checkRuleName(ruleName) {
|
||||
if (ruleName.length > 2) {
|
||||
var ide = jQuery('#jform_id').val();
|
||||
if (ide == 0) {
|
||||
ide = -1;
|
||||
}
|
||||
checkRuleName_server(ruleName, ide).done(function(result) {
|
||||
if(result.name && result.message){
|
||||
// show notice that functioName is okay
|
||||
jQuery.UIkit.notify({message: result.message, timeout: result.timeout, status: result.status, pos: 'top-right'});
|
||||
jQuery('#jform_name').val(result.name);
|
||||
// now start search for where the function is used
|
||||
usedin(result.name, ide);
|
||||
} else if(result.message){
|
||||
// show notice that ruleName is not okay
|
||||
jQuery.UIkit.notify({message: result.message, timeout: result.timeout, status: result.status, pos: 'top-right'});
|
||||
jQuery('#jform_name').val('');
|
||||
} else {
|
||||
// set an error that message was not send
|
||||
jQuery.UIkit.notify({message: Joomla.JText._('COM_COMPONENTBUILDER_VALIDATION_RULE_NAME_ALREADY_TAKEN_PLEASE_TRY_AGAIN'), timeout: 7000, status: 'danger', pos: 'top-right'});
|
||||
jQuery('#jform_name').val('');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// set an error that message was not send
|
||||
jQuery.UIkit.notify({message: Joomla.JText._('COM_COMPONENTBUILDER_YOU_MUST_ADD_AN_UNIQUE_VALIDATION_RULE_NAME'), timeout: 5000, status: 'danger', pos: 'top-right'});
|
||||
jQuery('#jform_name').val('');
|
||||
}
|
||||
}
|
||||
// check Function Name
|
||||
function checkRuleName_server(ruleName, ide){
|
||||
var getUrl = "index.php?option=com_componentbuilder&task=ajax.checkRuleName&format=json";
|
||||
if(token.length > 0){
|
||||
var request = 'token='+token+'&name='+ruleName+'&id='+ide;
|
||||
}
|
||||
return jQuery.ajax({
|
||||
type: 'POST',
|
||||
url: getUrl,
|
||||
dataType: 'jsonp',
|
||||
data: request,
|
||||
jsonp: 'callback'
|
||||
});
|
||||
}
|
160
admin/models/forms/validation_rule.xml
Normal file
160
admin/models/forms/validation_rule.xml
Normal file
@ -0,0 +1,160 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form
|
||||
addrulepath="/administrator/components/com_componentbuilder/models/rules"
|
||||
addfieldpath="/administrator/components/com_componentbuilder/models/fields"
|
||||
>
|
||||
<fieldset name="details">
|
||||
<!-- Default Fields. -->
|
||||
<!-- Id Field. Type: Text (joomla) -->
|
||||
<field
|
||||
name="id"
|
||||
type="text" class="readonly" label="JGLOBAL_FIELD_ID_LABEL"
|
||||
description ="JGLOBAL_FIELD_ID_DESC" size="10" default="0"
|
||||
readonly="true"
|
||||
/>
|
||||
<!-- Date Created Field. Type: Calendar (joomla) -->
|
||||
<field
|
||||
name="created"
|
||||
type="calendar"
|
||||
label="COM_COMPONENTBUILDER_VALIDATION_RULE_CREATED_DATE_LABEL"
|
||||
description="COM_COMPONENTBUILDER_VALIDATION_RULE_CREATED_DATE_DESC"
|
||||
size="22"
|
||||
format="%Y-%m-%d %H:%M:%S"
|
||||
filter="user_utc"
|
||||
/>
|
||||
<!-- User Created Field. Type: User (joomla) -->
|
||||
<field
|
||||
name="created_by"
|
||||
type="user"
|
||||
label="COM_COMPONENTBUILDER_VALIDATION_RULE_CREATED_BY_LABEL"
|
||||
description="COM_COMPONENTBUILDER_VALIDATION_RULE_CREATED_BY_DESC"
|
||||
/>
|
||||
<!-- Published Field. Type: List (joomla) -->
|
||||
<field name="published" type="list" label="JSTATUS"
|
||||
description="JFIELD_PUBLISHED_DESC" class="chzn-color-state"
|
||||
filter="intval" size="1" default="1" >
|
||||
<option value="1">
|
||||
JPUBLISHED</option>
|
||||
<option value="0">
|
||||
JUNPUBLISHED</option>
|
||||
<option value="2">
|
||||
JARCHIVED</option>
|
||||
<option value="-2">
|
||||
JTRASHED</option>
|
||||
</field>
|
||||
<!-- Date Modified Field. Type: Calendar (joomla) -->
|
||||
<field name="modified" type="calendar" class="readonly"
|
||||
label="COM_COMPONENTBUILDER_VALIDATION_RULE_MODIFIED_DATE_LABEL" description="COM_COMPONENTBUILDER_VALIDATION_RULE_MODIFIED_DATE_DESC"
|
||||
size="22" readonly="true" format="%Y-%m-%d %H:%M:%S" filter="user_utc" />
|
||||
<!-- User Modified Field. Type: User (joomla) -->
|
||||
<field name="modified_by" type="user"
|
||||
label="COM_COMPONENTBUILDER_VALIDATION_RULE_MODIFIED_BY_LABEL"
|
||||
description="COM_COMPONENTBUILDER_VALIDATION_RULE_MODIFIED_BY_DESC"
|
||||
class="readonly"
|
||||
readonly="true"
|
||||
filter="unset"
|
||||
/>
|
||||
<!-- Access Field. Type: Accesslevel (joomla) -->
|
||||
<field name="access"
|
||||
type="accesslevel"
|
||||
label="JFIELD_ACCESS_LABEL"
|
||||
description="JFIELD_ACCESS_DESC"
|
||||
default="1"
|
||||
required="false"
|
||||
/>
|
||||
<!-- Ordering Field. Type: Numbers (joomla) -->
|
||||
<field
|
||||
name="ordering"
|
||||
type="number"
|
||||
class="inputbox validate-ordering"
|
||||
label="COM_COMPONENTBUILDER_VALIDATION_RULE_ORDERING_LABEL"
|
||||
description=""
|
||||
default="0"
|
||||
size="6"
|
||||
required="false"
|
||||
/>
|
||||
<!-- Version Field. Type: Text (joomla) -->
|
||||
<field
|
||||
name="version"
|
||||
type="text"
|
||||
class="readonly"
|
||||
label="COM_COMPONENTBUILDER_VALIDATION_RULE_VERSION_LABEL"
|
||||
description="COM_COMPONENTBUILDER_VALIDATION_RULE_VERSION_DESC"
|
||||
size="6"
|
||||
readonly="true"
|
||||
filter="unset"
|
||||
/>
|
||||
<!-- Dynamic Fields. -->
|
||||
<!-- Name Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="name"
|
||||
label="COM_COMPONENTBUILDER_VALIDATION_RULE_NAME_LABEL"
|
||||
size="40"
|
||||
description="COM_COMPONENTBUILDER_VALIDATION_RULE_NAME_DESCRIPTION"
|
||||
class="input-large-text"
|
||||
required="true"
|
||||
/>
|
||||
<!-- Short_description Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="short_description"
|
||||
label="COM_COMPONENTBUILDER_VALIDATION_RULE_SHORT_DESCRIPTION_LABEL"
|
||||
size="40"
|
||||
maxlength="150"
|
||||
description="COM_COMPONENTBUILDER_VALIDATION_RULE_SHORT_DESCRIPTION_DESCRIPTION"
|
||||
class="text_area"
|
||||
required="true"
|
||||
filter="HTML"
|
||||
message="COM_COMPONENTBUILDER_VALIDATION_RULE_SHORT_DESCRIPTION_MESSAGE"
|
||||
hint="COM_COMPONENTBUILDER_VALIDATION_RULE_SHORT_DESCRIPTION_HINT"
|
||||
/>
|
||||
<!-- Inherit Field. Type: Existingvalidationrules. (custom) -->
|
||||
<field
|
||||
type="existingvalidationrules"
|
||||
name="inherit"
|
||||
label="COM_COMPONENTBUILDER_VALIDATION_RULE_INHERIT_LABEL"
|
||||
description="COM_COMPONENTBUILDER_VALIDATION_RULE_INHERIT_DESCRIPTION"
|
||||
class="list_class"
|
||||
multiple="false"
|
||||
default="0"
|
||||
required="false"
|
||||
button="false"
|
||||
/>
|
||||
<!-- Php Field. Type: Textarea. (joomla) -->
|
||||
<field
|
||||
type="textarea"
|
||||
name="php"
|
||||
label="COM_COMPONENTBUILDER_VALIDATION_RULE_PHP_LABEL"
|
||||
rows="30"
|
||||
cols="15"
|
||||
description="COM_COMPONENTBUILDER_VALIDATION_RULE_PHP_DESCRIPTION"
|
||||
class="text_area span12"
|
||||
filter="raw"
|
||||
hint="COM_COMPONENTBUILDER_VALIDATION_RULE_PHP_HINT"
|
||||
required="true"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<!-- Access Control Fields. -->
|
||||
<fieldset name="accesscontrol">
|
||||
<!-- Asset Id Field. Type: Hidden (joomla) -->
|
||||
<field
|
||||
name="asset_id"
|
||||
type="hidden"
|
||||
filter="unset"
|
||||
/>
|
||||
<!-- Rules Field. Type: Rules (joomla) -->
|
||||
<field
|
||||
name="rules"
|
||||
type="rules"
|
||||
label="Permissions in relation to this validation_rule"
|
||||
translate_label="false"
|
||||
filter="rules"
|
||||
validate="rules"
|
||||
class="inputbox"
|
||||
component="com_componentbuilder"
|
||||
section="validation_rule"
|
||||
/>
|
||||
</fieldset>
|
||||
</form>
|
Reference in New Issue
Block a user