Attendance View, Admin Rights & Auto-Sync Guide

by Alex Johnson 48 views

This article outlines the steps to enhance your application by adding an attendance view link, managing administrator permissions via a Google Sheet, and ensuring automatic synchronization of attendance data. Follow these instructions to streamline your workflow and maintain data integrity.

1. Adding an Attendance View Link to welcome.html

Enhance User Experience with Easy Access to the Attendance View. Adding a direct link to the attendance view on the welcome page improves user experience by providing quick and easy access to this essential feature. This ensures that all users, regardless of their roles, can efficiently navigate to the attendance section. Here’s how to implement this enhancement:

Requirements

  • Add a “勤怠ビュー” (Attendance View) button or link to the top page.
  • Ensure it matches the appearance and layout of other menu items.
  • The destination URL should be ?view=attendance.

Implementation Details

To add the attendance view link, you will need to modify the welcome.html file. This involves adding a new menu item that adheres to the existing card UI design. Here’s a step-by-step guide:

  1. Open welcome.html: Access the welcome.html file in your project directory. This is the file that generates the main landing page users see when they log in.

  2. Locate the Menu Section: Find the section in the HTML code where the menu items are defined. This is usually within a <nav> or <div> element that contains the other menu links or buttons.

  3. Add a New Menu Item: Insert a new <a> or <button> element for the attendance view link. Ensure that this new element is styled consistently with the existing menu items to maintain a uniform look and feel.

    <a href="?view=attendance" class="menu-item">
        勤怠ビュー (Attendance View)
    </a>
    

    or

    <button onclick="window.location.href='?view=attendance'" class="menu-item">
        勤怠ビュー (Attendance View)
    </button>
    
  4. Styling the New Element: Apply the same CSS classes and styles to the new element as the other menu items. This ensures visual consistency. Check the existing menu items for their CSS classes and apply them to your new element.

  5. Verify Accessibility: Make sure the new link is accessible to all users. Ensure the text is readable and the link is keyboard accessible for users who rely on keyboard navigation.

  6. Test the Link: After adding the link, thoroughly test it to ensure it redirects to the correct URL (?view=attendance) and functions as expected.

  7. No Special Permissions Required: This link should be accessible to all users, regardless of their staff permissions. Ensure that no permission checks are blocking access to this link.

By following these steps, you can seamlessly integrate the attendance view link into the welcome page, enhancing the usability and accessibility of your application. Consistent design and easy access are key to a positive user experience, making it simpler for users to manage their attendance.

2. Managing Administrator Permissions via NotificationSettings

Simplify Admin Rights Management with Google Sheets. Centralizing the management of administrator permissions within a Google Sheet streamlines the process, making it easier to grant or revoke access without altering code. This method enhances flexibility and reduces the need for code modifications. Here’s how to set it up:

Requirements

  • Control the display of the administrator panel based on the “管理者” (Administrator) column in the NotificationSettings sheet.
  • Grant administrator permissions to “拠点リーダー” (Location Leaders) by updating this column.
  • Manage permissions solely through sheet updates.

Implementation Details

The existing isAdminUser_() function already references the NotificationSettings sheet, so no code changes are necessary. The focus is on establishing a clear operational workflow:

  1. Access the NotificationSettings Sheet: Open the Google Sheet named NotificationSettings. This sheet contains a list of all employees and their corresponding settings.
  2. Locate the “管理者” (Administrator) Column: Find the column labeled “管理者” (Administrator). This column is used to determine whether a user has administrator privileges.
  3. Granting Admin Permissions:
    • In the “メール” (Email) column, find the row corresponding to the employee you want to grant administrator permissions to.
    • In the “管理者” (Administrator) column of that row, change the value to TRUE. This action flags the user as an administrator.
  4. Revoking Admin Permissions:
    • To revoke administrator permissions, change the value in the “管理者” (Administrator) column back to FALSE.
  5. Saving Changes: The changes you make in the Google Sheet are automatically saved. The system will recognize these changes almost immediately, and the administrator menu will be displayed or hidden accordingly.
  6. Testing the Permissions: After making changes, verify that the administrator menu is displayed or hidden as expected for the affected users. This ensures that the permissions are correctly applied.

Operational Procedure (For Staff)

  1. Open Google Sheets: Navigate to Google Sheets and open the NotificationSettings sheet.
  2. Locate the “メール” Column: Find the “メール” (Email) column, which lists all employees.
  3. Modify the “管理者” Column:
    • To grant admin rights, change the “管理者” (Administrator) column for the desired employee to TRUE.
    • To revoke admin rights, change the “管理者” (Administrator) column for the desired employee to FALSE.
  4. Changes Take Effect Immediately: The administrative menu will appear or disappear based on the updated settings.

By implementing this system, managing administrator permissions becomes straightforward and easily auditable. Google Sheets provides a user-friendly interface for making these changes, and the real-time update ensures that permissions are always current.

3. Verifying VisitAttendance Automatic Synchronization Trigger

Ensure Data Integrity with Automatic Synchronization. Maintaining up-to-date data is crucial for accurate reporting and decision-making. The automatic synchronization of VisitAttendance data ensures that the system reflects the most current information without manual intervention. Here’s how to verify and set up the automatic synchronization trigger:

Requirements

  • Automatic data updates depend on the execution of the syncVisitAttendance() function.
  • A daily automatic update requires running ensureVisitAttendanceSyncTrigger() once.

Implementation Details

To ensure the automatic synchronization of attendance data, the ensureVisitAttendanceSyncTrigger() function must be executed once to set up a daily trigger. This trigger will automatically run the syncVisitAttendance() function, keeping the data up-to-date.

  1. Open the Script Editor: Access the script editor in your Google Apps Script project. This is where you can view and run the functions that automate tasks within your application.

  2. Locate the ensureVisitAttendanceSyncTrigger() Function: Find the function named ensureVisitAttendanceSyncTrigger() in the script editor. This function is responsible for creating the daily trigger.

  3. Manually Execute the Function: Run the ensureVisitAttendanceSyncTrigger() function manually. This will create a new daily trigger that executes the syncVisitAttendance() function.

    • Select the function from the function list in the script editor.
    • Click the “Run” button to execute the function.
  4. Verify Trigger Creation: After running the function, verify that the daily trigger has been created. You can do this by navigating to the “Triggers” section in the script editor.

    • In the script editor, click the “Triggers” icon (it usually looks like a clock).
    • Check that there is a trigger set up to run the syncVisitAttendance() function daily.

Operational Procedure (One-Time Task for Admins)

  1. Open the Script Editor: Navigate to the script editor within your Google Apps Script project.
  2. Run ensureVisitAttendanceSyncTrigger: Select the ensureVisitAttendanceSyncTrigger function from the function list and manually execute it.
  3. Automatic Trigger Generation: This action automatically generates a daily trigger.
  4. Daily Synchronization: The system will now automatically synchronize data daily.
  5. Check Triggers (If Issues Arise): If the synchronization stops, check the “Triggers” screen to ensure the trigger is still active and functioning correctly.

By following these steps, you can ensure that your attendance data is automatically synchronized daily, providing accurate and up-to-date information for all users. Regular verification of the trigger ensures the ongoing integrity of your data.

Conclusion

By implementing these steps, you can enhance the user experience of your application, streamline the management of administrator permissions, and ensure the automatic synchronization of attendance data. These improvements contribute to a more efficient, user-friendly, and reliable system.

For more information on Google Apps Script and its capabilities, visit the official Google Apps Script documentation.