constructor()

in src/routes/Plugin/PluginRuleHandle/GeneralContextRuleHandle.js [32:68]


  constructor(props) {
    super(props);
    props.onRef(this);
    const { handle } = props;
    const keys = {};
    const handleData = {};
    handlers.forEach(v => {
      keys[v] = [];
    });
    // format handle
    try {
      const handleJSON = JSON.parse(handle);
      handlers.forEach(handleName => {
        if (Array.isArray(handleJSON[handleName])) {
          keys[handleName] = handleJSON[handleName].map(data => {
            const Guid = guid();
            if (!handleData[handleName]) {
              handleData[handleName] = {};
            }
            handleData[handleName][Guid] = data;
            return Guid;
          });
        } else {
          keys[handleName] = [guid()];
        }
      });
    } catch (e) {
      handlers.forEach(handleName => {
        keys[handleName] = [guid()];
      });
    }
    this.keys = keys;
    this.handleData = handleData;
    this.state = {
      currentType: handlers[0]
    };
  }