lodash#forIn JavaScript Examples

The following examples show how to use lodash#forIn. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Mappers.js    From sampo-ui with MIT License 6 votes vote down vote up
makeObject = (obj) => {
  const o = {}
  forIn(obj, function (value, key) {
    // If the variable name contains "__", an object
    // will be created as the value
    // E.g. { place__id: '1' } -> { place: { id: '1' } }
    set(o, key.replace(/__/g, '.'), value.value)
  })
  return o
}
Example #2
Source File: index.js    From hzero-front with Apache License 2.0 6 votes vote down vote up
@Bind()
  handleConfig() {
    const {
      dataSource: { dataSourceDetail = {}, extConfigs = [] },
    } = this.props;
    const { extConfig = '{}' } = dataSourceDetail;
    const columnList = [];
    // 获取参数
    forIn(JSON.parse(extConfig), (value, key) => {
      if (
        findIndex(extConfigs, (o) => {
          return o.itemCode === key;
        }) === -1
      ) {
        columnList.push({
          name: key,
          value,
          columnId: uuid(),
          _status: '',
        });
      }
    });
    this.setState({
      dataSource: columnList,
    });
  }
Example #3
Source File: index.js    From hzero-front with Apache License 2.0 6 votes vote down vote up
@Bind()
  handleScrollDom() {
    const [tableHeader, tableBody] = document.getElementsByClassName('hreport');
    const tableDom = document.getElementsByClassName('hreport-table-body')[0];
    const tableHeaderDom = document.getElementsByClassName('hreport-table-head')[0];
    if (tableDom && tableHeaderDom) {
      if (tableDom.scrollHeight > (tableDom.offsetHeight || tableDom.clientHeight)) {
        tableHeaderDom.setAttribute('style', 'width:calc(100% - 15px)');
      }
    }
    if (tableDom && tableHeader && tableBody) {
      tableDom.addEventListener('scroll', () => {
        const { scrollLeft } = tableDom;
        const obj = {};
        const str = tableHeader.getAttribute('style');

        str.split(';').forEach((item) => {
          if (item) {
            const arr = item.split(': ') || [];
            const [name, value] = arr;
            obj[name] = value;
          }
        });
        obj['margin-left'] = `-${scrollLeft}px`;
        let styleStr = '';
        forIn(obj, (value, key) => {
          styleStr = `${styleStr}${key}: ${value};`;
        });
        tableHeader.setAttribute('style', styleStr);
      });
    }
  }
Example #4
Source File: index.js    From hzero-front with Apache License 2.0 6 votes vote down vote up
@Bind()
  handleScrollDom() {
    const [tableHeader, tableBody] = document.getElementsByClassName('hreport');
    const tableDom = document.getElementsByClassName('hreport-table-body')[0];
    const tableHeaderDom = document.getElementsByClassName('hreport-table-head')[0];
    if (tableDom && tableHeaderDom) {
      if (tableDom.scrollHeight > (tableDom.offsetHeight || tableDom.clientHeight)) {
        tableHeaderDom.setAttribute('style', 'width:calc(100% - 15px)');
      }
    }
    if (tableDom && tableHeader && tableBody) {
      tableDom.addEventListener('scroll', () => {
        const { scrollLeft } = tableDom;
        const obj = {};
        const str = tableHeader.getAttribute('style');

        str.split(';').forEach((item) => {
          if (item) {
            const arr = item.split(': ') || [];
            const [name, value] = arr;
            obj[name] = value;
          }
        });
        obj['margin-left'] = `-${scrollLeft}px`;
        let styleStr = '';
        forIn(obj, (value, key) => {
          styleStr = `${styleStr}${key}: ${value};`;
        });
        tableHeader.setAttribute('style', styleStr);
      });
    }
  }
Example #5
Source File: InventoryPopupSettings.js    From CyberStateRP with MIT License 4 votes vote down vote up
popupSettings = () => {
    const itemMenus = {
        1: [],
        2: [],
        3: [],
        4: [{
            text: 'Split up',
            handler: sqlId => {
                window.inventoryAPI.show(false)
                window.modalAPI.show('item_split', JSON.stringify({
                    itemSqlId: sqlId,
                }))
            },
        }],
        5: [],
        6: [],
        7: [],
        8: [],
        9: [],
        10: [],
        11: [],
        12: [],
        13: [],
        14: [],
        15: [],
        16: [{
            text: 'Look',
            handler: sqlId => {
                alt.emit('events.emitServer', 'showDocuments', sqlId)
            },
        }],
        17: [],
        18: [],
        19: [],
        20: [],
        21: [],
        22: [],
        23: [],
        24: [],
        25: [{
            text: 'Use',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.useHealth', sqlId)
            },
        }],
        26: [],
        27: [],
        28: [],
        29: [{
            text: 'Look',
            handler: sqlId => {
                alt.emit('events.emitServer', 'documents.showFaction', -1)
            },
        }],
        30: [{
            text: 'Drink',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.eat', sqlId)
            },
        }],
        31: [{
            text: 'Eat',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.eat', sqlId)
            },
        }],
        32: [{
            text: 'Eat',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.eat', sqlId)
            },
        }],
        33: [{
            text: 'Suck',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.eat', sqlId)
            },
        }],
        34: [{
            text: 'To get',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.takeSmoke', sqlId)
            },
        }],
        35: [{
            text: 'Drink',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.eat', sqlId)
            },
        }],
        36: [],
        37: [{
            text: 'Split up',
            handler: sqlId => {
                window.inventoryAPI.show(false)
                window.modalAPI.show('item_split', JSON.stringify({
                    itemSqlId: sqlId,
                }))
            },
        }],
        38: [{
            text: 'Split up',
            handler: sqlId => {
                window.inventoryAPI.show(false)
                window.modalAPI.show('item_split', JSON.stringify({
                    itemSqlId: sqlId,
                }))
            },
        }],
        39: [{
            text: 'Split up',
            handler: sqlId => {
                window.inventoryAPI.show(false)
                window.modalAPI.show('item_split', JSON.stringify({
                    itemSqlId: sqlId,
                }))
            },
        }],
        40: [{
            text: 'Split up',
            handler: sqlId => {
                window.inventoryAPI.show(false)
                window.modalAPI.show('item_split', JSON.stringify({
                    itemSqlId: sqlId,
                }))
            },
        }],
        41: [],
        42: [],
        43: [],
        44: [],
        45: [],
        46: [],
        47: [],
        48: [],
        49: [],
        50: [],
        51: [],
        52: [],
        53: [],
        54: [{
            text: 'Parking',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.parkCarByKeys', sqlId)
            },
        },
        {
            text: 'Doors',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.lockCarByKeys', sqlId)
            },
        },
        {
            text: 'Search',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.searchCarByKeys', sqlId)
            },
        },
        {
            text: 'Deliver',
            handler: sqlId => {
                const item = window.inventoryAPI.getItem(sqlId)
                if (!item) return alt.emit('nError', 'No keys found!')
                const { model } = item.params
                if (window.clientStorage.sqlId !== item.params.owner) {
                    return alt.emit('nError', `You are not the owner ${model}!`)
                }
                window.inventoryAPI.show(false)
                alt.emit('choiceMenu.show', 'accept_fix_car', sqlId)
            },
        },
        {
            text: 'To sell',
            handler: sqlId => {
                const item = window.inventoryAPI.getItem(sqlId)
                if (!item) return alt.emit('nError', 'No keys found!')
                const { model } = item.params
                if (window.clientStorage.sqlId !== item.params.owner) {
                    return alt.emit('nError', `You are not the owner ${model}!`)
                }
                window.inventoryAPI.show(false)
                window.modalAPI.show('sell_player_car', JSON.stringify({ sqlId }))
            },
        },
        ],
        55: [{
            text: 'To use',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.useDrugs', sqlId)
            },
        },
        {
            text: 'Split up',
            handler: sqlId => {
                window.inventoryAPI.show(false)
                window.modalAPI.show('item_split', JSON.stringify({
                    itemSqlId: sqlId,
                }))
            },
        },
        ],
        56: [{
            text: 'To use',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.useDrugs', sqlId)
            },
        },
        {
            text: 'Split up',
            handler: sqlId => {
                window.inventoryAPI.show(false)
                window.modalAPI.show('item_split', JSON.stringify({
                    itemSqlId: sqlId,
                }))
            },
        },
        ],
        57: [{
            text: 'To use',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.useDrugs', sqlId)
            },
        },
        {
            text: 'Split up',
            handler: sqlId => {
                window.inventoryAPI.show(false)
                window.modalAPI.show('item_split', JSON.stringify({
                    itemSqlId: sqlId,
                }))
            },
        },
        ],
        58: [{
            text: 'To use',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.useDrugs', sqlId)
            },
        },
        {
            text: 'Split up',
            handler: sqlId => {
                window.inventoryAPI.show(false)
                window.modalAPI.show('item_split', JSON.stringify({
                    itemSqlId: sqlId,
                }))
            },
        },
        ],
        59: [{
            text: 'Search',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.searchHouseByKeys', sqlId)
            },
        }],
        60: [{
            text: 'Look',
            handler: sqlId => {
                alt.emit('events.emitServer', 'documents.showFaction', -1)
            },
        }],
        61: [{
            text: 'Look',
            handler: sqlId => {
                alt.emit('events.emitServer', 'documents.showFaction', -1)
            },
        }],
        62: [{
            text: 'To smoke',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.useSmoke', sqlId)
            },
        }],
        63: [{
            text: 'Look',
            handler: sqlId => {
                alt.emit('events.emitServer', 'documents.showFaction', -1)
            },
        }],
        64: [{
            text: 'Look',
            handler: sqlId => {
                alt.emit('events.emitServer', 'documents.showFaction', -1)
            },
        }],
        65: [],
        66: [],
        67: [],
        68: [],
        69: [],
        70: [],
        71: [],
        72: [],
        73: [],
        74: [],
        75: [],
        76: [],
        77: [],
        78: [],
        79: [],
        80: [],
        81: [],
        82: [],
        83: [],
        84: [],
        85: [],
        86: [],
        87: [],
        88: [],
        89: [],
        90: [],
        91: [],
        92: [],
        93: [],
        94: [],
        95: [],
        96: [],
        97: [],
        98: [],
        99: [],
        100: [],
        101: [],
        102: [],
        103: [],
        104: [],
        105: [],
        106: [],
        107: [],
        108: [],
        109: [],
        110: [],
        111: [],
        112: [],
        113: [],
        114: [],
        115: [],
        116: [],
        117: [],
        118: [],
        119: [],
        120: [],
        121: [],
        122: [],
        123: [],
        124: [],
        125: [],
        126: [],
    }
    forIn(itemMenus, (value, key) => {
        itemMenus[key].push({
            text: 'Throw away',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.throw', sqlId)
            },
        })
    })
    delete itemMenus[4]
    return itemMenus
}
Example #6
Source File: InventoryPopupSettings.js    From CyberState with GNU General Public License v3.0 4 votes vote down vote up
popupSettings = () => {
    const itemMenus = {
        1: [],
        2: [],
        3: [],
        4: [{
            text: 'Разделить',
            handler: sqlId => {
                window.inventoryAPI.show(false)
                window.modalAPI.show('item_split', JSON.stringify({
                    itemSqlId: sqlId,
                }))
            },
        }],
        5: [],
        6: [],
        7: [],
        8: [],
        9: [],
        10: [],
        11: [],
        12: [],
        13: [],
        14: [],
        15: [],
        16: [{
            text: 'Посмотреть',
            handler: sqlId => {
                alt.emit('events.emitServer', 'showDocuments', sqlId)
            },
        }],
        17: [],
        18: [],
        19: [],
        20: [],
        21: [],
        22: [],
        23: [],
        24: [],
        25: [{
            text: 'Использовать',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.useHealth', sqlId)
            },
        }],
        26: [],
        27: [],
        28: [],
        29: [{
            text: 'Посмотреть',
            handler: sqlId => {
                alt.emit('events.emitServer', 'documents.showFaction', -1)
            },
        }],
        30: [{
            text: 'Выпить',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.eat', sqlId)
            },
        }],
        31: [{
            text: 'Съесть',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.eat', sqlId)
            },
        }],
        32: [{
            text: 'Съесть',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.eat', sqlId)
            },
        }],
        33: [{
            text: 'Пососать',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.eat', sqlId)
            },
        }],
        34: [{
            text: 'Достать',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.takeSmoke', sqlId)
            },
        }],
        35: [{
            text: 'Выпить',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.eat', sqlId)
            },
        }],
        36: [],
        37: [{
            text: 'Разделить',
            handler: sqlId => {
                window.inventoryAPI.show(false)
                window.modalAPI.show('item_split', JSON.stringify({
                    itemSqlId: sqlId,
                }))
            },
        }],
        38: [{
            text: 'Разделить',
            handler: sqlId => {
                window.inventoryAPI.show(false)
                window.modalAPI.show('item_split', JSON.stringify({
                    itemSqlId: sqlId,
                }))
            },
        }],
        39: [{
            text: 'Разделить',
            handler: sqlId => {
                window.inventoryAPI.show(false)
                window.modalAPI.show('item_split', JSON.stringify({
                    itemSqlId: sqlId,
                }))
            },
        }],
        40: [{
            text: 'Разделить',
            handler: sqlId => {
                window.inventoryAPI.show(false)
                window.modalAPI.show('item_split', JSON.stringify({
                    itemSqlId: sqlId,
                }))
            },
        }],
        41: [],
        42: [],
        43: [],
        44: [],
        45: [],
        46: [],
        47: [],
        48: [],
        49: [],
        50: [],
        51: [],
        52: [],
        53: [],
        54: [{
            text: 'Парковка',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.parkCarByKeys', sqlId)
            },
        },
        {
            text: 'Двери',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.lockCarByKeys', sqlId)
            },
        },
        {
            text: 'Поиск',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.searchCarByKeys', sqlId)
            },
        },
        {
            text: 'Доставить',
            handler: sqlId => {
                const item = window.inventoryAPI.getItem(sqlId)
                if (!item) return alt.emit('nError', 'Ключи не найдены!')
                const { model } = item.params
                if (window.clientStorage.sqlId !== item.params.owner) {
                    return alt.emit('nError', `Вы не владелец ${model}!`)
                }
                window.inventoryAPI.show(false)
                alt.emit('choiceMenu.show', 'accept_fix_car', sqlId)
            },
        },
        {
            text: 'Продать',
            handler: sqlId => {
                const item = window.inventoryAPI.getItem(sqlId)
                if (!item) return alt.emit('nError', 'Ключи не найдены!')
                const { model } = item.params
                if (window.clientStorage.sqlId !== item.params.owner) {
                    return alt.emit('nError', `Вы не владелец ${model}!`)
                }
                window.inventoryAPI.show(false)
                window.modalAPI.show('sell_player_car', JSON.stringify({ sqlId }))
            },
        },
        ],
        55: [{
            text: 'Употребить',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.useDrugs', sqlId)
            },
        },
        {
            text: 'Разделить',
            handler: sqlId => {
                window.inventoryAPI.show(false)
                window.modalAPI.show('item_split', JSON.stringify({
                    itemSqlId: sqlId,
                }))
            },
        },
        ],
        56: [{
            text: 'Употребить',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.useDrugs', sqlId)
            },
        },
        {
            text: 'Разделить',
            handler: sqlId => {
                window.inventoryAPI.show(false)
                window.modalAPI.show('item_split', JSON.stringify({
                    itemSqlId: sqlId,
                }))
            },
        },
        ],
        57: [{
            text: 'Употребить',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.useDrugs', sqlId)
            },
        },
        {
            text: 'Разделить',
            handler: sqlId => {
                window.inventoryAPI.show(false)
                window.modalAPI.show('item_split', JSON.stringify({
                    itemSqlId: sqlId,
                }))
            },
        },
        ],
        58: [{
            text: 'Употребить',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.useDrugs', sqlId)
            },
        },
        {
            text: 'Разделить',
            handler: sqlId => {
                window.inventoryAPI.show(false)
                window.modalAPI.show('item_split', JSON.stringify({
                    itemSqlId: sqlId,
                }))
            },
        },
        ],
        59: [{
            text: 'Поиск',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.searchHouseByKeys', sqlId)
            },
        }],
        60: [{
            text: 'Посмотреть',
            handler: sqlId => {
                alt.emit('events.emitServer', 'documents.showFaction', -1)
            },
        }],
        61: [{
            text: 'Посмотреть',
            handler: sqlId => {
                alt.emit('events.emitServer', 'documents.showFaction', -1)
            },
        }],
        62: [{
            text: 'Курить',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.useSmoke', sqlId)
            },
        }],
        63: [{
            text: 'Посмотреть',
            handler: sqlId => {
                alt.emit('events.emitServer', 'documents.showFaction', -1)
            },
        }],
        64: [{
            text: 'Посмотреть',
            handler: sqlId => {
                alt.emit('events.emitServer', 'documents.showFaction', -1)
            },
        }],
        65: [],
        66: [],
        67: [],
        68: [],
        69: [],
        70: [],
        71: [],
        72: [],
        73: [],
        74: [],
        75: [],
        76: [],
        77: [],
        78: [],
        79: [],
        80: [],
        81: [],
        82: [],
        83: [],
        84: [],
        85: [],
        86: [],
        87: [],
        88: [],
        89: [],
        90: [],
        91: [],
        92: [],
        93: [],
        94: [],
        95: [],
        96: [],
        97: [],
        98: [],
        99: [],
        100: [],
        101: [],
        102: [],
        103: [],
        104: [],
        105: [],
        106: [],
        107: [],
        108: [],
        109: [],
        110: [],
        111: [],
        112: [],
        113: [],
        114: [],
        115: [],
        116: [],
        117: [],
        118: [],
        119: [],
        120: [],
        121: [],
        122: [],
        123: [],
        124: [],
        125: [],
        126: [],
    }
    forIn(itemMenus, (value, key) => {
        itemMenus[key].push({
            text: 'Выбросить',
            handler: sqlId => {
                alt.emit('events.emitServer', 'item.throw', sqlId)
            },
        })
    })
    delete itemMenus[4]
    return itemMenus
}