npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-my-crud

v1.0.3

Published

Vue.js Module to handle the boring CRUD operations. Provides slots for results and modal window for displaying form to edit data.

Downloads

10

Readme

About NEA Strong

Collaboration tool for tracking events, tasks and notes for archiving and easy retrieval.

Usage

Overview

Manages interaction with API to fetch and store changes to results.

Available Props

itemModel - REQUIRED Name of Model CRUD is responsible, in snake_case

itemName - REQUIRED Display name for the CRUD

basePath - Base path for the model, if other than /model(s). See Paths for details

getPath - Custom path to API for fetching items

createPath - Custom path to API for creating item

updatePath - Custom path to API for updating item

deletePath - Custom path to API for deleting item

seedResults - Accepts array of results instead of calling API path to fetch items

additionalFields - Object of items to add to each item prior to submission to API

itemCallback - Accepts object of item fields with functions that will be run anytime the specified field is processed through parseFormData

Example
<crud :itemCallback="{users: formatUsers}"></crud>

methods() {
    formatUsers(users) {
        // Format users
        return _.map(users, function(user) {
            return user.id;
        });
    },
} 

no-modal-footer - Disables the footer for the modal window. Requires addition of custom action buttons

no-modal-buttons - Removes buttons from modal footer, but keeps footer. Allows for insertion of custom buttons in footer-button slot.

handle-errors - Boolean - Disables toast notification triggered by catch() method for axios call.

Paths

Paths are determined by pluralizing itemModel and adding to path (i.e. itemModel: user becomes users)

Action | Method | Default -------|--------|--------- createItem | POST | /basePath/itemModel + 's' updateItem | PUT | /basePath/itemModel + 's'/item_id deleteItem | DELETE | /basePath/itemModel + 's'/item_id saveItems | POST | /basePath/itemModel + 's'

Methods

parseFormData

Loops over all results and creates FormData object

fetchItems

Makes call to API to retrieve results

submitForm, createForm, editForm, deleteForm

Opens modal, populates (and clears) data into form. When using editForm the item is cloned and becomes separate item, requiring results array to be refreshed to contain current data

createItem, updateItem, deleteItem

Parses form data and submits to the respective default or specified path

saveItems

Process entire results array and submits to createItem path, or pass array of items to save

pushItem

Add item to results array

popItem

Remove item with specified index from array

Listeners

Trigger events in the crud by assigning a reference to the instance and using $emit

Example
<crud ref="crud"></crud>

methods() {
        createUser(user) {
            // ... do something
            this.$refs.crud.$emit('create-form');
        },
    } 
    

create-form, edit-form, submit-form - Creates blank form or accepts item as input to populate fields create-item, update-item, delete-item - Accepts item as input then process expected

Emitters

crud-initialized

Emitted when CRUD is created()

fetch-items

Only emitted when using seed results, to trigger parent call to update results

item-saved

After item is successfully added or updated to the database.

item-created

After NEW item is successfully saved to database.

item-updated

After EXISTING item is successfully updated in the database

item-deleted

After item is successfully removed from the database

item-pushed

After item is successfully added to the results array

item-popped

After item is successfully removed from the results array

Slots

modal-footer - Displays footer for modal window.

DEFAULT - Displayed with Submit and Cancel buttons.

SCOPE - None

footer-button - Displays inside footer of modal window.

DEFAULT - Empty

SCOPE - item, submitForm, cancelForm, createItem, editItem, deleteItem