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

we-bases

v0.2.0

Published

ya Ali

Downloads

3

Readme

Package we-bases

What does this package do?

  1. set Global method mixin in project
    • $_asset(path)
    • $_name(path, text)
    • $_color(slug)
    • $_dialog(properties)
    • $_helper(slug)
    • $_openModal(name, data = {}, $can = null)
    • $_closeModal(slug)
  2. set Global data mixin in project
    • modal = false
    • modal_data = {}
  3. set Global components
    • use <we-base /> for dialog and helper
  4. set Global directive
    • example v-can:client-edit.disable="postObject"
    • example v-soon.disable="client-list"
  5. has {urlGenerator}
  6. Load Category names and store in local storage
  • this package a special package for willaengine project

Prerequisites

  • [x] use package we-axios.

##install

npm install we-bases

##Usage

use in main:

import Base from 'we-bases'
Vue.use(Base, options);

defult Options:

const options = {
    basic_roues: {
         login: "/ms-login",
         main: "/main/home",
         user: "/user/list",
         originHostName: 'www.willaengine.ir',
         api: 'https://www.willaengine.ir'
    },
    prefix: 'v1'
};

##Mixin

###Assets use for image or file static from https://www.willaengine.ir

if Vue.config.devtools == true => subpath equal '/'

if Vue.config.devtools == true => subpath equal 'https://www.willaengine.ir/'

$_asset(path);

###Nomenclature For names that are going to change according to the customer's needs

get list name from server and save in local storage

$_name(path, text);
//example $_name('common.task.name', 'ثبت $_name')

define default name in install package and projects:

const Task = {
    my_task: {name: ' وظایف من ', name_en: ' My Tasks '},
    my_request: {name: ' درخواست های من ', name_en: ' My Requests '},
    title: {
        add: {name: 'تعریف وظیفه ', name_en: ' Define a Task '},
        add_category: {name: 'افزودن نوع وظیفه', name_en: ' Add a Task Type '},
        list_category: {name: ' مدیریت انواع وظیفه ', name_en: ' Manage the Task types '},
        add_status: {name: ' افزودن وضعیت وظیفه ', name_en: '  Add a Task Status  '},
        list_status: {name: 'مدیریت وضعیت وظیفه ', name_en: '  Manage the Task Status  '},
        detail: {name: 'جزیئات وظیفه ', name_en: '  Task Details  '},
        change_status: {name: 'تغییر وضعیت وظیفه ', name_en: 'Change Task Status'},
    },
    name: 'وظیفه',
    name_en: 'Task',
    names: 'وظایف',
    name_ens: 'Tasks',
    begin_date: {name: 'تاریخ شروع وظیفه', name_en: 'Task Begin Date'},
    end_date: {name: ' تاریخ اتمام وظیفه ', name_en: 'Task End Date'},
    category: {name: 'نوع وظیفه', name_en: 'Task Type'},
    status: {name: 'وضعیت وظیفه', name_en: 'Task Status'},
    responsibility: {name: 'مسئول وظیفه', name_en: 'Task Responsibility'},
};
Vue.prototype.$defaultNames['task'] = Task;

###Colors All WillaEngine project packages that have a special color should be added colors to Vue.prototype.$specialColors Variable

use in component

$_color(slug);
//example $_color('task')

add in package in install OR add in Projects

const taskColors = {
task: 'red',
task_status: 'brown',
task_category: 'yellow'
}
Object.assign(Vue.prototype.$specialColors, taskColors);

###Dialog

$_dialog(properties)
//example $_dialog({success: () => {removeCategory(item)}})

default properties variable:

const properties = {
    type: "delete",
    success: function() {
        return "";
    },
    close: function() {
        return "";
    },
    message:
        "آیا از حذف آیتم مطمئن هستید؟ امکان بازگشت وجود نخواهد داشت.",
    title: " تایید حذف ",
    titleEn: " Remove Confirmation ",
    color: "red",
    cancelButtonText: "انصراف",
    confirmButtonText: "حذف",
    cancelButtonColor: "cyan",
    confirmButtonColor: "red"
}

###Helper Passing the slug will prompt you to request this api v1/help/${slug} and get response from server for this slug

$_helper(slug)
//example $_helper('index-category')

###Modal

in all components you access to variable data => modal and modal_data

modal is boolean

modal_data is object passing from $_openmodal

$_openModal(name, data = {}, $can = null)
$_closeModal()
//example $_openModal(name, data = {}, $can = null)

name is component name except modal

example:// component name is modal_task_list => name passing in $_openModal('name') is task_list

data access in modal component modal_data variable

$can is object policy $can.model $can.method

$can = {model: 'Client', method: 'index', data}
//data is passing data to directive can
//if data not passing, use data passing to $_openModal()

// OR Use 
$can = "Client::index"
// In this case, the data becomes the data used in the $_openModal()

##Directive

###Policy must be define class policy in packages and merge with Vue.prototype.$policies

in directory policy file TaskStatusPolicy.js

export default class TaskStatusPolicy {
    //permissions => Object.values(rootPermissions[module])
    //module => Vue.prototype.$module.current
    //rootPermissions => Vue.prototype.$permission

    index({module, rootPermissions, permissions}) {
        return permissions.includes('manage-task-status');
    }
    
    create({permissions}) {
        return permissions.includes('manage-task-status');
    }
    
    update({permissions}, object) {
        return permissions.includes('manage-task-status') || object.owner;
    }
    
    delete({permissions}, object) {
        return permissions.includes('manage-task-status') || object.owner;
    }
    
}

in directory policy file index

import TaskStatus from './TaskStatusPolicy'
import Task from './TaskPolicy'
Vue.prototype.$policies['TaskStatus'] = TaskStatus;
Vue.prototype.$policies['Task'] = Task;
//disable
<div v-can:client-show.disable="client" >{{client.name}}</div>

//hidden
<div v-can:client-show="client" >{{client.name}}</div>

client-show => client is model name and show is method name split with -

###CommingSoon must be define array in packages and merge with Vue.prototype.$soon

//hidden
<div v-soon="'client'" ><component /></div>

//disable
<div v-soon.disable="'client'" ><btn /></div>

Usage URL Generator

file ./url.js

import {urlGenerator} from 'we-bases'
//use prefix in import Base from 'we-bases'
//Vue.use(Base, {prefix: 'v1'});

const urls = {
	//Cities && Districts
	indexCities: "cities",
	showCity: "city/:city",
}
export default url = urlGenerator(urls);

use in other file

import urls from './url'
import {axios} from 'we-axios'
$axios.get(urls('showCity', {city: 1}))