Skip to content

Commit

Permalink
Merge pull request #23 from imadeelnazar/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
imadeelnazar authored Aug 8, 2024
2 parents b2dd546 + 7e7d6a2 commit 3adb528
Show file tree
Hide file tree
Showing 8 changed files with 335 additions and 70 deletions.
1 change: 0 additions & 1 deletion classes/wpaf-ajax-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ function wp_custom_pagination($max_num_pages, $args = [], $class = 'pagination',
global $wp_rewrite;

// Again - hard coded, you should make it dynamic though

$jquery_code = "<script>
jQuery(document).ready(function($){
$('.wpaf-page-numbers a').on('click',function(e) {
Expand Down
12 changes: 6 additions & 6 deletions dist/bundle.js

Large diffs are not rendered by default.

49 changes: 48 additions & 1 deletion src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@
}
.wp-category-item-field code {
background: #f0f0f1;
padding: 10px 10px 12px 0px;
padding: 0px 10px 0px 10px;
margin-left: 15px;
margin-top: 0px !important;
top: -2px;
display: flex;
position: relative;
align-content: center;
justify-content: center;
align-items: center;
}
.wp-category-form-wrap-static code{
background:#f0f0f1;
Expand Down Expand Up @@ -226,4 +230,47 @@ display: inline-block;
.wp-category-form-wrap-static .dialog-box[open] .dialog-box-inner{
width: 250px;
height: 90px;
}
.preset-wrap {
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-content: center;
justify-content: flex-start;
align-items: center;
}
.wp-category-item-field label span{
display:none;
}

.wp-category-item {
display: flex;
flex-direction: column;
}
.wp-category-item-title .wp-category-item,
.wp-category-form-wrap-dynamic .wp-category-item{
flex-direction: row;
}
.wp-category-item textarea {
max-width: 300px;
margin-top: 14px;
min-height: 100px;
}
span.error {
position: fixed;
background: #333;
color: #fff;
padding: 15px;
z-index: 999;
top: 0;
bottom: 0;
height: 100px;
width: 400px;
left: 0;
right: 0;
margin: auto;
display: flex;
align-content: center;
justify-content: center;
align-items: center;
}
110 changes: 69 additions & 41 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ const App = () => {
const [ errorMsgWpcfLogic, setErrorMsgWpcfLogic ] = useState( '' );
const [ errorMsgWpcfSortBy, setErrorMsgWpcfSortBy ] = useState( '' );

// Method to dismiss error messages
const dismissError = (setError) => {
setError('');
};

// Use the useState hook to create a state variable 'categories' and the setCategories function to update it.
const [categories, setCategories] = useState([]);
Expand Down Expand Up @@ -146,6 +150,7 @@ useEffect(() => {
wpcfLogic: "",
wpcfSortBy: "",
});
const [option, setoption] = useState('link');

// Use the useState hook to create a state variable 'editContactId' and the setEditContactId function to update it
const [editContactId, setEditContactId] = useState(null);
Expand All @@ -157,7 +162,11 @@ useEffect(() => {
// Get the name and value of the input field that triggered the event
const fieldName = event.target.getAttribute("name");
const fieldValue = event.target.value;
if (fieldName === 'facetType') {
setoption(event.target.value);
}

// console.log(fieldName);
// Create a new object that is a copy of the current form data
const newFormData = { ...addFormData };
// Update the value of the field in the new object that corresponds to the input field that triggered the event
Expand Down Expand Up @@ -188,52 +197,52 @@ useEffect(() => {
const handleAddFormSubmit = (event) => {
event.preventDefault();

// if(addFormData.fullName === ''){
// setErrorMsgName('Label cannot be left empty!');
// return false;
// }
if(addFormData.fullName === ''){
setErrorMsgName('Label cannot be left empty!');
return false;
}
// setErrorMsgName('');

// if ( addFormData.facetType === '' ){
// setErrorMsgfacetType('Facet Type cannot be left empty!');
// return false;
// }
if ( addFormData.facetType === '' ){
setErrorMsgfacetType('Facet Type cannot be left empty!');
return false;
}
// setErrorMsgfacetType('');

// if(addFormData.dataSource === ''){
// setErrorMsgDataSource('Data Source cannot be left empty!');
// return false;
// }
if(addFormData.dataSource === ''){
setErrorMsgDataSource('Data Source cannot be left empty!');
return false;
}
// setErrorMsgDataSource('');

// if(addFormData.defaultLabel === ''){
// setErrorMsgDefaultLabel('Data Source cannot be left empty!');
// return false;
// }
if(addFormData.defaultLabel === ''){
setErrorMsgDefaultLabel('Data Source cannot be left empty!');
return false;
}
// setErrorMsgDefaultLabel('');

// if(addFormData.valueModifier === ''){
// setErrorMsgValueModifier('Data Source cannot be left empty!');
// return false;
// }
if(addFormData.valueModifier === ''){
setErrorMsgValueModifier('Data Source cannot be left empty!');
return false;
}
// setErrorMsgValueModifier('');

// if(addFormData.postsperpage === ''){
// setErrorMsgpostsperpage('Data Source cannot be left empty!');
// return false;
// }
if(addFormData.postsperpage === ''){
setErrorMsgpostsperpage('Data Source cannot be left empty!');
return false;
}
// setErrorMsgpostsperpage('');

// if(addFormData.wpcfLogic === ''){
// setErrorMsgWpcfLogic('Data Source cannot be left empty!');
// return false;
// }
if(addFormData.wpcfLogic === ''){
setErrorMsgWpcfLogic('Data Source cannot be left empty!');
return false;
}
// setErrorMsgWpcfLogic('');

// if(addFormData.wpcfSortBy === ''){
// setErrorMsgWpcfSortBy('Data Source cannot be left empty!');
// return false;
// }
if(addFormData.wpcfSortBy === ''){
setErrorMsgWpcfSortBy('Data Source cannot be left empty!');
return false;
}
// setErrorMsgWpcfSortBy('');

const newContact = {
Expand Down Expand Up @@ -325,15 +334,15 @@ const handleDeleteClick = (contactId) => {
{ value: 'cselect', label: 'Dropdown (cSelect)' },
{ value: 'hierarchy', label: 'Hierarchy' },
{ value: 'search', label: 'Search' },
{ value: 'autocomplete', label: 'Autocomplete' },
{ value: 'slider', label: 'Slider' },
{ value: 'date_range', label: 'Date Range' },
{ value: 'number_range', label: 'Number Range' },
{ value: 'proximity', label: 'Proximity' },
{ value: 'radio', label: 'Radio' },
{ value: 'rating', label: 'Star Rating' },
{ value: 'pager', label: 'Pager' },
{ value: 'sort', label: 'Sort' },
// { value: 'autocomplete', label: 'Autocomplete' },
// { value: 'slider', label: 'Slider' },
// { value: 'date_range', label: 'Date Range' },
// { value: 'number_range', label: 'Number Range' },
// { value: 'proximity', label: 'Proximity' },
// { value: 'radio', label: 'Radio' },
// { value: 'rating', label: 'Star Rating' },
// { value: 'pager', label: 'Pager' },
// { value: 'sort', label: 'Sort' }
];

return (
Expand Down Expand Up @@ -365,6 +374,15 @@ const handleDeleteClick = (contactId) => {
handleClickOpen={handleClickOpen}
handleCategories={categories}
handleDataType={dataType_o}
errorMsgName={errorMsgName}
errorMsgfacetType={errorMsgfacetType}
errorMsgDataSource={errorMsgDataSource}
errorMsgDefaultLabel={errorMsgDefaultLabel}
errorMsgValueModifier={errorMsgValueModifier}
errorMsgpostsperpage={errorMsgpostsperpage}
errorMsgWpcfLogic={errorMsgWpcfLogic}
errorMsgWpcfSortBy={errorMsgWpcfSortBy}
dismissError={dismissError} // Add this prop
/>
) : (
<ReadOnlyRow
Expand Down Expand Up @@ -399,6 +417,16 @@ const handleDeleteClick = (contactId) => {
handleAddFormChange={handleAddFormChange}
dataType_o={dataType_o}
categories={categories}
selectedOption={option}
errorMsgName={errorMsgName}
errorMsgfacetType={errorMsgfacetType}
errorMsgDataSource={errorMsgDataSource}
errorMsgDefaultLabel={errorMsgDefaultLabel}
errorMsgValueModifier={errorMsgValueModifier}
errorMsgpostsperpage={errorMsgpostsperpage}
errorMsgWpcfLogic={errorMsgWpcfLogic}
errorMsgWpcfSortBy={errorMsgWpcfSortBy}
dismissError={dismissError} // Add this prop
/>
<strong className="footer-pull-right">Design and Developed by <a href="https://wpscience.com">WPScience</a></strong>
</div>
Expand Down
Loading

0 comments on commit 3adb528

Please sign in to comment.