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

@beisen/upaas-user-selector

v0.0.19

Published

UserSelector

Downloads

71

Readme

UserSelector

  • 更新信息 目前选人组件已内置Tita真实数据,如不使用内置数据,isUseInitial为false即可,但使用时得手动在Reducers中添加接口。 测试环境的接口已部署跨域访问,线上还未部署。故当测试使用的是测试环境,tita-inc

参数

Props ----- without Redux

hidden: false, // 是否渲染 默认false
singleSelect: true // 单人选人,没有高级模式
offset: {}, // 组件位置偏移量 offset = {left: '10px',top: '20px'},
TenantId: '204348', // 租户ID
UserId: '100368554', // 用户ID
apiType: 'tita', // 接口产品 
isUseInitial: true, // 是否使用内置接口
onSure: () => {}, // 精简模式下 返回点击的人 数据格式 高级模式下 确定回调 返回已选择的数组
onClose: () => {}, // 高级模式下 取消回调 

默认内置接口

export default class InitialUrls {
 constructor(TenantId, UserId) {
 const tempTita = 'http://www.tita-inc.com/api/v1/' + TenantId + '/' + UserId + '/';
 this.tita = {
 usedUserUrl: tempTita + 'Contact',
 searchUrl: tempTita + 'user',
 staffUrl: tempTita + 'org/GetMySubordinates?lv=2&type=0',
 departmentUrl: tempTita + 'department/All',
 depUserUrl: tempTita + 'department/DepartmentOfUser?department_id='
 }
 }
 gettita(apiType) {
 switch(apiType) {
 case 'usedUserUrl':
 return this.tita[apiType] + '?v=' + (new Date()).getTime();
 case 'searchUrl':
 return this.tita[apiType] + '?v=' + (new Date()).getTime();
 default:
 return this.tita[apiType]
 }
 }
}

Props ---- width Redux(Initialize)

multi: false, // 默认精简模式
usedusers: [], // 常用人员
staffs: [], // 下属信息
departments: [], // 部门信息
results: [] // 已选择人员

简单预览

import React, {Component, PropTypes} from 'react'
import {render} from 'react-dom'
import App from './src/index.js';

class Demo extends Component{
 render () {
 const offset = {
 left: '10px',
 top: '20px'
 };
 // tita接口数据
 const Data = {
 "101893065":{
 "Id":101893065,
 "Name":"袁园",
 "Email":"[email protected]",
 "UserAvatar":{"Original":null,"Small":null,"Medium":null,"Big":null,"HasAvatar":false,"Color":"#b9cc4f"}
 },
 "103875086":{
 "Id":103875086,
 "Name":"郭美山",
 "Email":"[email protected]",
 "UserAvatar":{"Original":"http://cache.tita.com/Image/110006/324d5a07a3984689a6a5304d13902567_o.png","Small":"http://cache.tita.com/Image/110006/324d5a07a3984689a6a5304d13902567_s.png","Medium":"http://cache.tita.com/Image/110006/324d5a07a3984689a6a5304d13902567_m.png","Big":null,"HasAvatar":true,"Color":null}}
 };
 const usedusers = Object.values(Data);
 return (
 <App usedusers={usedusers} offset={offset} />
 )
 }
}

使用 with Redux

需复制app目录下 UserSelector.js文件 至Reducers中

import React, {Component, PropTypes} from 'react'
import {render} from 'react-dom'
import ConfigureStore from './app/configureStore';
import { Provider, connect } from 'react-redux';
import usReducers from './app/modules/UserSelector';
import * as usActions from './app/modules/UserSelector';
import Immutable from 'immutable';
import { toJS } from 'immutable';

const store = ConfigureStore(usReducers) ;

import App from './src/index.js';

@connect(
 state => state.toJS(),
 {...usActions}
)

class Demo extends Component{

 constructor(props) {
 super(props)
 this.state = {
 hidden: false
 }
 }

 onSure(temp) {
 console.log(temp)
 }

 setShow() {
 this.setState({hidden: !this.state.hidden})
 }

 render () {
 const offset = {
 left: '10px',
 top: '20px'
 }
 const data = {
 TenantId: '204348',
 UserId: '100368554',
 apiType: 'tita',
 isUseInitial: true
 }
 return (
 <div>
 <App {...this.props} offset={offset} {...data} onSure={this.onSure} hidden={this.state.hidden} />
 <button onClick={this.setShow}>show</button>
 </div>
 )
 }
}


render(
 <Provider store={store}>
 <Demo />
 </Provider>,
 document.getElementById('content')
);