Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 4713

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Latest Questions

Author
  • 61k
Author
Asked: November 27, 20242024-11-27T02:33:08+00:00 2024-11-27T02:33:08+00:00

Build HR Management System using MongoDB and ToolJet (Part 4: Leave Requests)

  • 61k

Request Leaves

This is the last application and this application will act as a dashboard for all the employees for requesting the leaves and getting the stats on their past leaves.

To build this application, clone the last application that we built, edit the cloned app and remove all the widgets except the header and sidebar. Remove all the queries, rename the application from Employees and Requests to Request Leaves , and Disable the Request leaves button on the sidebar and enable others.

requests

Building the UI

  • Rename the header text as <h1>🏖️Leave Scheduler</h1>
  • Drag another Text widget and set the text value to Your recent leave requests:
  • Place a ListView widget, a button, a modal, and two statistics widgets as shown in the image below

requests

  • Edit the ListView widget, and set the List Data field value to {{queries.listRequests.data[0].leaves}}
  • In list view widget, place the text widgets and set the following values:
  • Leave requested for date: {{moment(listItem.start_date).format("DD-MM-YYYY")}}
  • No. of Days: {{listItem.leave_days}}
  • Status: {{listItem.leave_days}}
  • You can style the text color of Status(approved, rejected, requested) text programmatically. Go to the Styles tab and click on the Fx button next to Text Color and set this value: {{listItem.status === "approved" ? "green" : listItem.status === "rejected" ? "red" : "blue"}}

requests

  • Click on the button widget to edit its properties, go to the handlers and add an event handler to show the modal that we added in the previous step.
  • After adding the event handler, click on the button to show the modal. When the modal shows up, you can drag on drop widgets on it to build a form
  • For labels use text widgets, datepicker widget for getting input for the start date, and a number input widget for the Number of days field.
  • Edit date picker properties, set default date to {{moment().format("YYYY-MM-DD")}} and date format to YYYY-MM-DD
  • For the Number input widget, you can set the maximum and minimum value according to your preference.
  • Add a button for submitting the leave request, it will have two event handlers – one for closing the modal and the other for running the query that will add a request to the database. For now, just add one handler for closing the modal, we will add another once we create the queries.

requests

  • On the first Statistics widget, set the Primary Value Label as Leaves Approved and Primary value to {{queries.approvedCount.data.count}} , and toggle on the Hide secondary value as this is not required.
  • On the second Statistics widget, set the Primary Value Label as Allocated leaves , we will hardcode the Primary value to 24 , set Secondary Value Label as Leave Balance and Secondary Value as {{24- queries.approvedCount.data.count}}

requests


Build the queries

listRequests

This query will return all those documents that match with the email of the currently logged-in user in ToolJet.

  • Create a new MongoDB query, select Find Many Operation and enter the collection name employees
  • In the Filter field, enter {email: "{{globals.currentUser.email}}"} – here we are getting the email of the logged-in user through the exposed variable.
  • Go to the Advanced tab, and enable the Run query on page load? option.
  • Hit Save and Run button to save and execute the query – You'll see the updated data on the listview widget.

requests

leaveRequest

This query will update a document and add a new object for leave request in the database.

  • Create a new MongoDB query, select Update One Operation and enter the collection name employees
  • In the Filter field enter {"email": "{{globals.currentUser.email}}"}
  • In the Update field enter {$push:{"leaves":{"start_date": "{{moment(components.datepicker1.value).toISOString(true)}}", "leave_days":{{components.numberinput1.value}}, "status": "requested"}}}
  • Hit Save button to save the query. Don't hit Run because it will create an empty object in the database since there is no value in the form yet.
  • Now, click on the button to show the modal, select the submit button, and the remaining event handler for running this query.

requests

approvedCount

This query returns the total count of the documents that have status field as approved.

  • Create a new MongoDB query, select Count Operation and enter the collection name employees
  • In the Filter field enter {"leaves.status": "approved"}
  • Go to the Advanced tab, and enable the Run query on page load? option.
  • Hit Save and Run button to save and execute the query – You'll see the value on the statistics widget gets updated.

requests

Finally, You can now release the last application by clicking the Release button on the top right of the app editor.

requests


Connecting the applications on the sidebar of each application

Now that we have all 4 applications released – All you need to do is to make the applications Public by clicking on the share button on the navbar of App-editor. After making the application public, create a custom shareable URL for all 4 applications.

For connecting all 4 applications, you'll need to edit the buttons in the sidebar of each application and use the Go to App action for On Click event handler.

release

Note: For making this change you'll need to create a new version from the released version first and then release it again for this change to be included.


Voila!! 🎉 You have successfully built an HR Management system that includes a suite of 4 different applications 🚀

If you have any queries related to building applications with ToolJet or just want to hang out in the community of low-code applications builders just drop us a Hi in our Slack Community. 🚀

beginnersjavascriptprogrammingwebdev
  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 0
  • Best Answers 0
  • Users 2k
  • Popular
  • Answers
  • Author

    ES6 - A beginners guide - Template Literals

    • 0 Answers
  • Author

    Understanding Higher Order Functions in JavaScript.

    • 0 Answers
  • Author

    Build a custom video chat app with Daily and Vue.js

    • 0 Answers

Top Members

Samantha Carter

Samantha Carter

  • 0 Questions
  • 20 Points
Begginer
Ella Lewis

Ella Lewis

  • 0 Questions
  • 20 Points
Begginer
Isaac Anderson

Isaac Anderson

  • 0 Questions
  • 20 Points
Begginer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.